[英]Utilizing BorderLayout on JFrame. ( Using Container)
GUI的新增功能,我试图创建一个简单的JFrame,其中两个JTextAreas彼此相邻放置,而JPanel在底部。
public class Demo extends JFrame
{
JPanel panel;
JTextArea JTextArea1;
JTextArea JTextArea2;
DecisionPanel decisionPanel;
public Demo()
{
super( "Black Jack Server" );
JFrame f = new JFrame();
f.setSize( 400, 400 ); ;
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
f.setVisible( true );
DecisionPanel decisionPanel = new DecisionPanel();
f.getContentPane().add( decisionPanel );
JTextArea1 = new JTextArea();
add( JTextArea1);
JTextArea2 = new JTextArea();
add( JTextArea2 );
}
}
我是否使用BorderLayout获得所需的结果? 如果是这样,我应该如何处理?
您可以嵌套JPanels并...
JTextAreas
放在自己的JScrollPanes
, JPanel
将JScrollPanes
放入GridLayout(1, 2)
(1行,两列)中 JPanel
成BorderLayout
使用JPanel
在BorderLayout.CENTER
位置 JPanel
放在BorderLayout.PAGE_END
位置。
就像是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.