【发布时间】:2013-12-31 21:51:58
【问题描述】:
我真的不明白为什么我的代码不能显示这张牛的图片,有什么建议吗?我根据我的信息正确地做了一切。所以我不太确定出了什么问题。我使用eclipse,程序没有显示错误。因此,如果有人可以提供帮助,将不胜感激。提前致谢。
package Zeus;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class Main extends JFrame{
public static final int WIDTH = 400;
public static final int HEIGHT = 300;
public static final int SCALE = 2;
private ImageIcon COW;
private static JLabel C0W;
Main() {
setLayout(new FlowLayout());
COW = new ImageIcon(getClass().getResource("/Cow Clicker/Resource/COW.png"));
C0W = new JLabel(COW);
}
public static void main(String[] args) {
JFrame Squishy = new JFrame("Squishy");
Squishy.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Squishy.setResizable(false);
Squishy.setVisible(true);
Squishy.setSize(WIDTH*SCALE, HEIGHT*SCALE);
Squishy.setLocationRelativeTo(null);
Squishy.add(C0W);
}
}
【问题讨论】:
标签: java image swing embedded-resource