Size of GridLayout

B

Bjorn Abelli

...
How do I set the size of one "cell" in a GridLayout?

You don't...

To "set the size on a singular cell" is rather another paradigm on how
layouts are made, than the underlying premises on how the LayoutManagers
work.

The use of exact pixel sizes was more or less abandoned for the use of
relative sizes. This is to some degree based on the premise that you would
probably prefer the look of the layout to adapt more to the actual
platform...

To make a long story short:

Say for example that you define a panel with a GridLayout(3, 2).

If the size of the panel is height 60 and width 30, then *each* cell will be
height 20 an width 15.

If you change the size of the panel to height 30 and width 60, the size of
*each* cell will be height 10 and width 30.

As you see the sizes of the individual cells are set "relatively" to the
size of the container.

// Bjorn A


P.S.

Questions of this kind should only be posted to comp.lang.java.gui.
No sense in posting it to comp.lang.java.programmer.
 
J

Jim Cobban

Jo said:
How do I set the size of one "cell" in a GridLayout?
GridLayout is simply a convenience mechanism to avoid you having to
explicitly specify the position of every component on a panel. The layout
takes the size information for each of the components and calculates where
they should be within the enclosing component. You set the size information
of the individual components. This can be done even after they are added to
the enclosing component as long as it is before you pack the frame the
component is displayed in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top