【发布时间】:2015-11-14 18:32:50
【问题描述】:
当我运行这段代码时:
public class Menu extends JFrame implements ActionListener {
JLabel logo = new JLabel("MyChef");
JPanel north = new JPanel();
public void main(String args[]){
new Menu();
}
Menu(){
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.setTitle("MyChef");
frame.setSize(500, 300);
frame.setVisible(true);
frame.setResizable(false);
frame.add(north, BorderLayout.NORTH);
north.add(logo);
}
public void actionPerformed(ActionEvent e){
}
}
窗口打开,但没有显示任何内容...我的标签在哪里?我很迷茫,因为我以前做过各种 GUI,要么我很愚蠢,要么我不知道!对不起,如果这是一个愚蠢的问题,我只是被困住了,我不得不发布这个。
【问题讨论】:
-
A common problem -- 提问前先搜索一下网站,很快就能找到解决办法。