我正在尝试将一个ImageIcon添加到我的JPanel中。
ImageIcon image = new ImageIcon("image.png", null);
JLabel label = new JLabel(image, JLabel.CENTER);
panel.add(label);
好的。图片位于与类相同的文件夹中...
com.package
|- mainclass.java
|- image.png
V
无论出于什么原因,图像图标无法在JPanel中显示。 我已经尝试使用try/catch进行排错,但是没有用。完全没有任何错误! 我使用的操作系统是Windows。