简体   繁体   English

帮助在Java中设置面板

[英]Help with setting up panels in Java

I'm new to Java awt, so I am having trouble with setting up panels. 我是Java awt的新手,因此在设置面板时遇到了麻烦。 I have one giant panel, which needs to hold 3 panels inside (photo is attached at the bottom). 我有一个巨型面板,里面需要容纳3个面板(照片附在底部)。 One will go on top(1), second one will be in the middle(3), and third goes on the bottom(2). 一个放在顶部(1),第二个放在中间(3),第三个放在底部(2)。 Any remaining space has to be divided equally between (1)/(3) and (3)/(2). 任何剩余空间都必须在(1)/(3)和(3)/(2)之间平均分配。 Also, the middle panel (3) is a table, so GridLayout has to be used. 而且,中间面板(3)是一个表,因此必须使用GridLayout。

How can I achieve this? 我该如何实现?

Thanks in advance! 提前致谢!

PS I've tried to draw it in MS Paint ( http://i45.tinypic.com/mwejkk.jpg ) PS我试图在MS Paint中绘制它( http://i45.tinypic.com/mwejkk.jpg

I don't understand all, I suggest : 我不太了解,我建议:

  • Use swing, not awt, so use JPanel 使用swing,而不是awt,所以使用JPanel

  • A BorderLayout, with your giant panel (jpanel) in middle, a jpanel at west ; 一个BorderLayout,中间有巨型面板(jpanel),西侧是jpanel; for this jpanel a BorderLayout, or BoxLayout, or GridLayout and put inside your 1 2 3 panels. 对于此jpanel,请使用BorderLayout或BoxLayout或GridLayout并将其放在您的1 2 3面板中。

... or use netbeans and matisse. ...或使用netbeans和matisse。

This will help you a lot. 将对您有很大帮助。 It's a Sun tutorial on BoxLayout. 这是有关BoxLayout的Sun教程。 It describes the stacked layout that you appear to need, and also how to make invisible components to add gaps in the extra space you mentioned. 它描述了您似乎需要的堆叠布局,以及如何使不可见的组件在您提到的额外空间中增加空隙。 For the middle pannel, put a GridLayout in that panel to do the things you need. 对于中间面板,在该面板中放置一个GridLayout来完成所需的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM