这是我写的一段代码:
import javax.swing.*;
public class Information extends JFrame{
public Information(){
this.setLocation(450,300);
this.setSize(200,100);
this.setVisible(true);
JPanel p = new JPanel();
JButton b = new JButton("牛逼");
p.add(b);
this.add(p);
}
public static void main(String [] args)
{
Information in = new Information();
}
}
我在用dos运行时,可以正常运行,但是如果在Eclipse中运行不能显示出按钮,不知道是什么原因!

解决方案 »

  1.   

    不太可能吧,我eclipse下可以,楼主搞错了吧
      

  2.   

    没发现问题
    把this.setVisible(true);放最后吧
    我以前听说国 AWT掩盖Swing的 而且作过测试确实
    因为AWT是重量级的总是显示在上面
      

  3.   

    你这话不假,但是这里全是swing 的控件
      

  4.   

    没发现问题
    把this.setVisible(true);放最后 
      

  5.   

    我试过了,的确把this.setVisible(true)放在最后,可以正确显示,但是不放在最后,在我同学电脑可以正常运行,但是在我的电脑上就不行了,感到很迷惑!