Tom Tucker
Tom Tucker

Reputation: 11916

Recommendation for LayoutManager

I have three components that need to be laid out vertically so that the top component takes 30% of the available height of the window, the middle one takes 20%, and the bottom one takes the rest of it.

As the window is resized, so will they, but their height relative to the window should remain the same.

Which layout manager should I use to implement this?

Upvotes: 0

Views: 65

Answers (3)

PeakGen
PeakGen

Reputation: 23035

Box layout set to Y Axis OR Grid bag layout.

In gridbag layout you can set the "weight" anyway. That is the one which is going to help you in 30%. 10% thing

Upvotes: 2

Jean Waghetti
Jean Waghetti

Reputation: 4727

Take a look at Visual Guide to Layout Managers and find which suits best for your requirements (or more than one - you can use more than one layout manager).

I would recommend GridBagLayout. It has a lot of "fine tunings". weigthy is the field of GridBagConstraints of your interest - it manages how the space will be distributed to elements in vertical when resized.

Upvotes: 2

jackrabbit
jackrabbit

Reputation: 5663

If you want to go with a standard layout manager, consult the visual guide. GridBagLayout is your best bet, I think.

I myself would probably use miglayout for the increased maintainability.

Both of these divide your panel in a grid. You can then assign resize weights to the columns and rows.

Upvotes: 2

Related Questions