Size of GridLayout

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

4/10/2004 3:27:50 PM
comp.lang.java.gui 8286 articles. 0 followers. Post Follow

2 Replies

Similar Articles

[PageSpeed] 26

"Jo" wrote...

> 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

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

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


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

4/10/2004 4:10:14 PM
"Jo" <mmmmm@spamtrap.com> wrote in message
> 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.

4/10/2004 9:12:07 PM