2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > java布局器嵌套_java swing布局嵌套

java布局器嵌套_java swing布局嵌套

时间:2021-06-24 13:06:35

相关推荐

java布局器嵌套_java swing布局嵌套

public void frame()

{

this.frame = new JFrame("用户注册");

//窗体基本属性

this.frame.setSize(600, 400);

this.frame.setLocationRelativeTo(null);

this.frame.setVisible(true);

this.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

//设置主面板,相当于外层div

JPanel jp = new JPanel(new BorderLayout());

//东西南北中,面板

JPanel jp1 = new JPanel(new FlowLayout());

JPanel jp2 = new JPanel(new FlowLayout());

JPanel jp3 = new JPanel(new GridLayout(10,2));

JPanel jp4 = new JPanel(new FlowLayout());

JPanel jp5 = new JPanel(new FlowLayout());

//加入主面板

jp.add(BorderLayout.NORTH,jp1);

jp.add(BorderLayout.SOUTH,jp2);

jp.add(BorderLayout.CENTER,jp3);

jp.add(BorderLayout.EAST,jp4);

jp.add(BorderLayout.WEST,jp5);

//标题

JLabel jl1 = new JLabel("用户注册",SwingConstants.CENTER);

jp1.add(jl1);

//中间面板

JButton jb2= new JButton("Btn");

JTextField jt = new JTextField("usrname");

JButton jb1 = new JButton("abc");

jp3.add(jt);

jp3.add(jb1);

jp3.add(jb2);

this.container = this.frame.getContentPane();

this.container.setBackground(Color.white);

this.container.add(jp);

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。