public void Wuziqi_jiemianUI(){
setTitle(title);
setSize(400, 400);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(2, 1));
JPanel jptop = new JPanel();
JLabel jltishi = new JLabel();
jltishi.setText(gametishi);
jltishi.setFont(new Font("宋体", Font.BOLD, 15));
jptop.add(jltishi,BorderLayout.CENTER);
add(jptop);
JPanel jpmain = new JPanel();
jpmain.setLayout(new FlowLayout());
JPanel jpmainright = new JPanel();
jpmainright.setLayout(new GridLayout(6, 1, 10, 10));
jpmainright.add(start);
jpmainright.add(setting);
jpmainright.add(help);
jpmainright.add(end);
jpmainright.add(version);
jpmainright.add(exit);
jpmain.add(qipan);
jpmain.add(jpmainright,BorderLayout.WEST);
add(jpmain);
JPanel jpbuttom = new JPanel();
jpbuttom.setLayout(new FlowLayout());
jpbuttom.setSize(100, 50);
jpbuttom.add(heitext);
jpbuttom.add(baitext);
add(jpbuttom,BorderLayout.SOUTH);
}
怎么做成这个布局效果?
2014-03-21 22:28
提问者采纳
1
2
3
4
5
6
7
jpmain.setlayout(
new
BorderLayout);
jpmain.add(panel1, BorderLayout.North);
JPanel centerPanel =
new
JPanel();
centerPanel.add(panel2);
//CenterPanel可能需要用到GridbayLayout来控panel2, 3的相对占的比例
centerPanel.add(panel3);
jpmain.add(centerPanel, BorderLayout.CENTER);
jpmain.add(panel4, BorderLayout.SOUTH);
public void Wuziqi_jiemianUI(){
setTitle(title);
setSize(400, 400);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(2, 1));
JPanel jptop = new JPanel();
JLabel jltishi = new JLabel();
jltishi.setText(gametishi);
jltishi.setFont(new Font("宋体", Font.BOLD, 15));
jptop.add(jltishi,BorderLayout.CENTER);
add(jptop);
JPanel jpmain = new JPanel();
jpmain.setLayout(new FlowLayout());
JPanel jpmainright = new JPanel();
jpmainright.setLayout(new GridLayout(6, 1, 10, 10));
jpmainright.add(start);
jpmainright.add(setting);
jpmainright.add(help);
jpmainright.add(end);
jpmainright.add(version);
jpmainright.add(exit);
jpmain.add(qipan);
jpmain.add(jpmainright,BorderLayout.WEST);
add(jpmain);
JPanel jpbuttom = new JPanel();
jpbuttom.setLayout(new FlowLayout());
jpbuttom.setSize(100, 50);
jpbuttom.add(heitext);
jpbuttom.add(baitext);
add(jpbuttom,BorderLayout.SOUTH);
}
怎么做成这个布局效果?
1
2
3
4
5
6
7
|
jpmain.setlayout(
new
BorderLayout);
jpmain.add(panel1, BorderLayout.North);
JPanel centerPanel =
new
JPanel();
centerPanel.add(panel2);
//CenterPanel可能需要用到GridbayLayout来控panel2, 3的相对占的比例
centerPanel.add(panel3);
jpmain.add(centerPanel, BorderLayout.CENTER);
jpmain.add(panel4, BorderLayout.SOUTH);
|