Moonlit
Moonlit

Reputation: 5409

Create Swing GUI with vertically stacked sections

I want to create a GUI in Swing which contains two vertical sections:

+-----------------------+
| labels,textfields     |
|   and buttons         |
+-----------------------+
|                       |
| chart display         |
|                       |
|                       |
+-----------------------+

I want the first section to take about 30% of the vertical space and the second about 70%. How can I achieve this with Java Swing?

Upvotes: 2

Views: 272

Answers (3)

Alfergon
Alfergon

Reputation: 5919

I would recomend using GridBagLayout for the cases in which you want to controll the size of the layout's components as it allows to put weights on the components.

How to use GridBagLayout

Upvotes: 3

Dan D.
Dan D.

Reputation: 32391

Use a layout manager like BorderLayout. The top one would go to BorderLayout.NORTH, the bigger one to BorderLayout.CENTER.

Upvotes: 2

Related Questions