0
我正在尝试创建一个看起来像纸牌的切换按钮。无论我放置img文件夹的位置如何,都无法显示图像。我使用下面的代码。用图标切换按钮
final JFrame frame = new JFrame("Toggle button test");
frame.setSize(500, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new FlowLayout());
ImageIcon icon = new ImageIcon("img/1.png");
JToggleButton jtbButton = new JToggleButton(icon);
frame.add(jtbButton);
frame.setVisible(true);