0
我遵守以下行为(在Windows 7平台上):摇摆的JComboBox怪异的行为
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame{
JPanel p;
JComboBox<String> l;
JLabel title;
public static void main(String[] arg){
Main m = new Main();
m.setVisible(true);
m.setSize(400,400);
m.p = new JPanel();
//m.l = new JComboBox<String>();
m.title = new JLabel("HELLO");
m.p.add(m.title);
m.setContentPane(m.p);
}
}
显示HELLO
,但如果我取消对实例化JComboBox
行,它不会显示任何内容。什么可能导致?你能重现错误吗?从我的评论
移动'm.setVisible(真);'在末端。 – 2011-12-22 10:35:25
对不起,我刚刚找到答案,我应该在JFrame上运行包,我已经忘记了;( – lc2817 2011-12-22 10:36:42
@HarryJoy它的工作,谢谢 – lc2817 2011-12-22 11:05:28