What layout manager will do this?

旧街凉风 提交于 2019-12-01 11:30:57

问题


OY, not enough rep points to post an image...

____________________________________________________
|joes pizza                                         |
|          pizza type  toppings         ----------- |
|                                       |         | |
|          cheese       mushrooms       | 15.00   | |
|          veggie       extra cheese    |         | |
|          pepperoni    bacon           |         | |
|                                       ----------  |
|  _______________________________________________  |
|  |  calculate total                             | |
|  ------------------------------------------------ |
|___________________________________________________|

I'm supposed to build this for class, where the options in the middle are radio buttons and check boxes, and I have all the components in my panels in my frame. All I have left to do is actionListener and make it look like this. We are learning Layout Managers, and have been given five (FlowLayout, BorderLayout, GridLayout, BoxLayout, CardLayout, and GridBagLayout).

I can't seem to make any of them look like this, though. They either all end up in a line or in some crazy staggered representation, or crowded in from border to border. Any suggestions? In case my setup is getting in the way, I have joe's pizza in a label, pizza type in a pane, toppings in a pane, the textArea on the right, and finally a button. I'm not looking for an answer or the code to make it happen, just want to know what tools I should be using. If I can't figure out the tools, I'll ask another question or ask in the comments. Thanks for any suggestions.

Tony


回答1:


You can nest JPanels with different layouts. Here is one way to go about it. Picture should say it all.



来源:https://stackoverflow.com/questions/21948289/what-layout-manager-will-do-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!