怎么我的这个java程序没有弹出窗口,再eclipse运行后没反应,求解答?
importjava.awt.*;importjavax.swing.*;publicclassTenButtonsextendsJFrame{publicstaticv...
import java.awt.*;
import javax.swing.*;
public class TenButtons extends JFrame {
public static void main(String[] args) {
new TenButtons();
}
public TenButtons() {
Container f = getContentPane();
f.setLayout(new GridLayout(2,1));
JPanel p1 = new JPanel(new GridLayout(1,1));
JPanel p2 = new JPanel(new GridLayout(2,1));
JPanel p3 = new JPanel(new GridLayout(1,1));
JPanel p4 = new JPanel(new GridLayout(1,1));
JPanel p5 = new JPanel(new GridLayout(1,1));
JPanel p6 = new JPanel(new GridLayout(2,2));
JPanel p7 = new JPanel(new GridLayout(1,1));
p1.add(new Button());
p2.add(new Button());
p2.add(new Button());
p3.add(new Button());
p4.add(new Button());
p5.add(new Button());
p6.add(new Button());
p6.add(new Button());
p6.add(new Button());
p6.add(new Button());
p7.add(new Button());
f.add(p1);
f.add(p2);
f.add(p3);
f.add(p4);
f.add(p5);
f.add(p6);
f.add(p7);
}
} 展开
import javax.swing.*;
public class TenButtons extends JFrame {
public static void main(String[] args) {
new TenButtons();
}
public TenButtons() {
Container f = getContentPane();
f.setLayout(new GridLayout(2,1));
JPanel p1 = new JPanel(new GridLayout(1,1));
JPanel p2 = new JPanel(new GridLayout(2,1));
JPanel p3 = new JPanel(new GridLayout(1,1));
JPanel p4 = new JPanel(new GridLayout(1,1));
JPanel p5 = new JPanel(new GridLayout(1,1));
JPanel p6 = new JPanel(new GridLayout(2,2));
JPanel p7 = new JPanel(new GridLayout(1,1));
p1.add(new Button());
p2.add(new Button());
p2.add(new Button());
p3.add(new Button());
p4.add(new Button());
p5.add(new Button());
p6.add(new Button());
p6.add(new Button());
p6.add(new Button());
p6.add(new Button());
p7.add(new Button());
f.add(p1);
f.add(p2);
f.add(p3);
f.add(p4);
f.add(p5);
f.add(p6);
f.add(p7);
}
} 展开
3个回答
展开全部
frame.setVisible(true);这个属性是,是否显示页面,加上试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
所有的窗口最后必须显式地 setVisible(true) 才可以在屏幕上显示,希望可以帮到你
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询