On Wed, 15 Jun 2005 17:50:30 GMT, Dimitris (GIS) wrote:
> Is there any method for adding compnents with the GridBagLayout?
> I have found that method on the internet but i don't remember where.
It is best to get the information direct from Sun
<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/GridBagLayout.html#addLayoutCom
ponent(java.awt.Component,%20java.lang.Object)>
<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/GridBagLayout.html#addLayoutCom
ponent(java.lang.String,%20java.awt.Component)>
For the lightweight entry point to the Sun Java 1.5 JavaDocs
<http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html>
..else..
<http://java.sun.com/j2se/1.5.0/docs/api/index.html?overview-summary.html>
HTH

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Thomas Fritsch - 15 Jun 2005 20:20 GMT
> On Wed, 15 Jun 2005 17:50:30 GMT, Dimitris (GIS) wrote:
>
[quoted text clipped - 4 lines]
> <http://java.sun.com/j2se/1.5.0/docs/api/java/awt/GridBagLayout.html#addLayoutCom
ponent(java.awt.Component,%20java.lang.Object)>
> <http://java.sun.com/j2se/1.5.0/docs/api/java/awt/GridBagLayout.html#addLayoutCom
ponent(java.lang.String,%20java.awt.Component)>
I don't agree. You usually do not call neither of these 2 methods directly.
Instead you call
<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Container.html#add(java.awt.Com
ponent,%20java.lang.Object)>
on your container,
like
container.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
// set attribute of constraints as needed...
container.add(component, constraints); // this will call the
GridBagLayout's addLayoutComponent method
> For the lightweight entry point to the Sun Java 1.5 JavaDocs
> <http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html>
> ..else..
> <http://java.sun.com/j2se/1.5.0/docs/api/index.html?overview-summary.html>

Signature
"TFritsch$t-online:de".replace(':','.').replace('$','@')
Andrew Thompson - 15 Jun 2005 20:22 GMT
>> On Wed, 15 Jun 2005 17:50:30 GMT, Dimitris (GIS) wrote:
>>
[quoted text clipped - 9 lines]
> <http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Container.html#add(java.awt.Com
ponent,%20java.lang.Object)>
> on your container, ..
Good point.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
> Is there any method for adding compnents with the GridBagLayout?
> I have found that method on the internet but i don't remember where.
>
> It is a method that we can call it "addComponents" and you parse 5 or 6
> variables (weightX, weightY, gridwidth,gridheight, etc etc)
There is nothing like this, but you can easily write your
own utility class to do it, or create a "GridBagLayoutPanel"
class that has this built in. If you use a lot of GridBagLayouts,
this will save a lot of code and make using GBL easier. In
most cases, you can get away with passing in just a single
integer consisting of flags. Here are the ones I use:
last in row
fill - none, vertical, horizontal, or both
weightx and weighty - three possible levels of both (0.00000001, 0.0001,
and 1.0)
flags for flush left, right, top, bottom (if not flush, a standard
spacing is used)
flag for double space left
anchors - N, S, W, E, NE, NW, SE, SW
All those flags fit in a single integer, and work for about 95%
of my needs (generally adding components left-to-right and
top-to-bottom). Two additional parameters for gridwidth and
gridx cover most of the other uses. Doing this has the added
benefits of standardizing the spacing in all of your layouts.