[5199] in java-interest
Re: How do I specify rows/columns for GridBagLayout?
daemon@ATHENA.MIT.EDU (Amy Fowler)
Wed Jan 31 22:23:11 1996
Date: Wed, 31 Jan 1996 17:46:08 -0800
From: Amy.Fowler@Eng.Sun.COM (Amy Fowler)
To: java@java.Eng.Sun.COM, java-interest@java.Eng.Sun.COM, jug@jug.org,
john@insightnews.com
>>It appears to me that when I use GridBagLayout and GridBagConstraints,
>>whatever I'm using them on -- whether it be a panel, window, frame, etc, --
>>the grid size is always 1x1.
>>
>>The GridBagConstraints gridx and gridy variables and gridwidth and
>>gridheight variables exist to place components on the grid. I want to be
>>able to use them.
The GridBag will dynamically grow to accommodate whatever number
of rows and columns you place components in -- you don't need to
specify a number of rows/columns up front. As soon as
you add a component with a gridx/gridy contsraint which is
beyond it's current grid, it will expand it's grid to accommodate.
>>
>>How can I specify the number of columns and rows in the grid? If I use:
>> setLayout(new GridLayout(10, 10));
>>then I can't use GridBagConstraints and GridBagLayout (I can but they don't
>>work), so I think this is not the answer I'm looking for.
GridLayout is a completely separate layout manager from
GridBagLayout (it's unfortunate that the naming could easily
lead one to assume otherwise).
>>
>>So I end up using such things as RELATIVE, BOTH, etc. rather than specific
>>grid positions. These work alright but they're not specific enough. Of
>>course, I don't want to tie the components to specific coordinates because I
>>want them to be flexible when the window changes size.
It's clear to me that we really need to get some good
documentation about how to use the GridBagLayout out on
the site. It's a very powerful layout manager, but many
can't figure out how to use it (i.e. you arn't alone!).
Regards,
Amy Moore-Fowler
Java Products Group
Sun Microsystems, Inc.
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com