[5350] in java-interest

home help back first fref pref prev next nref lref last post

RE: How do I specify rows/columns for GridBagLayout?

daemon@ATHENA.MIT.EDU (Groshe)
Tue Feb 6 12:04:07 1996

From: Groshe <gnicaj@iu.net>
To: "'Amy Fowler'" <Amy.Fowler@Eng.Sun.COM>,
        "java-interest@java.Eng.Sun.COM"
	 <java-interest@java.Eng.Sun.COM>,
        "java@java.Eng.Sun.COM"
	 <java@java.Eng.Sun.COM>,
        "john@insightnews.com"
	 <john@insightnews.com>,
        "jug@jug.org" <jug@jug.org>
Date: Thu, 1 Feb 1996 20:07:29 -0500

Is it possible to use a GridBagLayout to draw Images?
When I draw an image I need to specify the coordinates, but the GridBagLayout doesn't allow that - you just add it..
How can I get an Image on the GridBagLayout?

----------
From: 	Amy Fowler[SMTP:Amy.Fowler@Eng.Sun.COM]
Sent: 	Wednesday, January 31, 1996 8:46 PM
To: 	java@java.Eng.Sun.COM; java-interest@java.Eng.Sun.COM; jug@jug.org; john@insightnews.com
Subject: 	Re: How do I specify rows/columns for GridBagLayout?


>>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



-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post