java布局问题.这个怎么来布局
publicvoidWuziqi_jiemianUI(){setTitle(title);setSize(400,400);setVisible(true);setDef...
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); }
怎么做成这个布局效果? 展开
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); }
怎么做成这个布局效果? 展开
3个回答
展开全部
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);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询