【发布时间】:2013-06-23 20:37:39
【问题描述】:
当我运行代码时,它只会打开一个空窗口 我也很重要,无论什么是必要的
相关部分代码:
public class Game extends JFrame implements ActionListener,KeyListener{
private JLabel background;
....
public Game(){
background=new JLabel(new ImageIcon("/graphics/board.gif"));
...
this.add(background);
this.setSize(800,600);
this.setVisible(true);...
我尝试将 JLabel 添加到 JPanel,然后将其添加到框架中,但窗口中仍然没有显示任何内容
【问题讨论】:
-
我认为您为
JLabel使用了错误的构造函数(假设您不想显示 text "/graphics/board.gif")。跨度>
标签: java swing jframe jlabel imageicon