请问我的这个Java程序怎么修改才能避免覆盖,而四个JPanel又能按顺序自上而下按顺序输出来
importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;importjavax.swing.event.*...
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class zzz extends JFrame {
Container n=getContentPane();
JPanel n1,n2,n3,n4;
JLabel m1,m2,m3,m4,m5,m6,m7,m8,m9,m10;
public zzz(){
super("dhfjdkhf");
init();
myLayout();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
this.setVisible(true);
}
public void init(){
n1=new JPanel(); n2=new JPanel();
n3=new JPanel(); n4=new JPanel();
m1=new JLabel("fbf");m2=new JLabel("dfs");
m3=new JLabel("ret");m4=new JLabel("ur4");
m5=new JLabel("dgs");m6=new JLabel("cvb");
m7=new JLabel("bdf");m8=new JLabel("bh1");
m9=new JLabel("cbn");m10=new JLabel("nbc");
}
public void myLayout(){
n.setLayout(new BorderLayout());
m1.setLayout(new FlowLayout());
m2.setLayout(new FlowLayout());
m3.setLayout(new FlowLayout());
m4.setLayout(new FlowLayout());
n1.add(m1);
n2.add(m2); n2.add(m3);
n3.add(m4);n3.add(m5);n3.add(m6);
n4.add(m7); n4.add(m8); n4.add(m9);n4.add(m10);
n.add(n1);
n.add(n2);
n.add(n3);
n.add(n4);
n.add(n1,BorderLayout.NORTH);
n.add(n2,BorderLayout.CENTER);
n.add(n3,BorderLayout.CENTER);
n.add(n4,BorderLayout.SOUTH);
}
public static void main(String[] args) {
new zzz();
}
} 展开
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class zzz extends JFrame {
Container n=getContentPane();
JPanel n1,n2,n3,n4;
JLabel m1,m2,m3,m4,m5,m6,m7,m8,m9,m10;
public zzz(){
super("dhfjdkhf");
init();
myLayout();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
this.setVisible(true);
}
public void init(){
n1=new JPanel(); n2=new JPanel();
n3=new JPanel(); n4=new JPanel();
m1=new JLabel("fbf");m2=new JLabel("dfs");
m3=new JLabel("ret");m4=new JLabel("ur4");
m5=new JLabel("dgs");m6=new JLabel("cvb");
m7=new JLabel("bdf");m8=new JLabel("bh1");
m9=new JLabel("cbn");m10=new JLabel("nbc");
}
public void myLayout(){
n.setLayout(new BorderLayout());
m1.setLayout(new FlowLayout());
m2.setLayout(new FlowLayout());
m3.setLayout(new FlowLayout());
m4.setLayout(new FlowLayout());
n1.add(m1);
n2.add(m2); n2.add(m3);
n3.add(m4);n3.add(m5);n3.add(m6);
n4.add(m7); n4.add(m8); n4.add(m9);n4.add(m10);
n.add(n1);
n.add(n2);
n.add(n3);
n.add(n4);
n.add(n1,BorderLayout.NORTH);
n.add(n2,BorderLayout.CENTER);
n.add(n3,BorderLayout.CENTER);
n.add(n4,BorderLayout.SOUTH);
}
public static void main(String[] args) {
new zzz();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询