我的图片放在D:/begincode/Begin_SCG/src/gui/logo.bmp 下 我在代码中也是这样取得的
this.getContentPane().add(new MyPane(new ImageIcon("D:/begincode/Begin_SCG/src/gui/logo.bmp")), new XYConstraints(74, 227, 255, 48));
不知是GUI中不能加载.bmp文件 还是我的路径设置有问题 还请诸位大虾多多指教
this.getContentPane().add(new MyPane(new ImageIcon("D:/begincode/Begin_SCG/src/gui/logo.bmp")), new XYConstraints(74, 227, 255, 48));
不知是GUI中不能加载.bmp文件 还是我的路径设置有问题 还请诸位大虾多多指教
protected static ImageIcon createImageIcon(String path) {
System.out.println(path);
java.net.URL imgURL = GuiUtil.class.getClassLoader().getResource(path);
System.out.println(imgURL);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
}