这是Java Swing的问题,在上面一个panel中,怎么让那个下拉列表和文本框各处在左右两边的中间位置?
这是代码publicstaticJPanelgroup(){JPanelgroPane=newJPanel();JPanelpane1=newJPanel();JPane...
这是代码
public static JPanel group(){
JPanel groPane = new JPanel();
JPanel pane1 = new JPanel();
JPanel pane11 = new JPanel();
JPanel pane12 = new JPanel();
JPanel pane2 = new JPanel();
JTextArea eachGro = new JTextArea(10,30);
String[] string = {"第一次","第二次","第三次","第四次","第五次","第六次","第七次","第八次","第九次","第十次","第十一次","第十二次"};
JComboBox divGro = new JComboBox(string);
JLabel label1 = new JLabel("请选择你要查询的作业");
JLabel label2 = new JLabel("该次作业的分组情况如下");
pane1.setLayout(new BorderLayout());
pane1.add(label1,"North");
pane1.add(divGro,"Center");
pane1.setSize(500, 30);
pane2.setLayout(new BorderLayout());
pane2.add(label2,"North");
pane2.add(eachGro,"Center");
pane2.setSize(500,30);
groPane.setLayout(new FlowLayout());
groPane.add(pane1);
groPane.add(pane2);
return groPane;
} 展开
public static JPanel group(){
JPanel groPane = new JPanel();
JPanel pane1 = new JPanel();
JPanel pane11 = new JPanel();
JPanel pane12 = new JPanel();
JPanel pane2 = new JPanel();
JTextArea eachGro = new JTextArea(10,30);
String[] string = {"第一次","第二次","第三次","第四次","第五次","第六次","第七次","第八次","第九次","第十次","第十一次","第十二次"};
JComboBox divGro = new JComboBox(string);
JLabel label1 = new JLabel("请选择你要查询的作业");
JLabel label2 = new JLabel("该次作业的分组情况如下");
pane1.setLayout(new BorderLayout());
pane1.add(label1,"North");
pane1.add(divGro,"Center");
pane1.setSize(500, 30);
pane2.setLayout(new BorderLayout());
pane2.add(label2,"North");
pane2.add(eachGro,"Center");
pane2.setSize(500,30);
groPane.setLayout(new FlowLayout());
groPane.add(pane1);
groPane.add(pane2);
return groPane;
} 展开
3个回答
展开全部
把想要的界面先画个草图出来,然后再考虑布局。
追问
恩恩,谢谢,草图中的设计我现在没法给你看,设计的是表格上方的两个控件在左右两半的中间,请问高手有招吗?
追答
我觉得 JComboBox 和 JTextArea 一上一下放到窗口左边比较好。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
换个布局啊,你用gridbaglayout()可以实现的,用boxlayout也可以实现
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询