[5018] in java-interest

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

Re: problem with GridBagLayout

daemon@ATHENA.MIT.EDU (Christian Wiedmann)
Fri Jan 26 01:49:15 1996

To: java-interest@java.sun.com
Cc: wiedmann@infinity.com
In-Reply-To: Your message of "Thu, 25 Jan 1996 06:36:45 PST."
             <199601251436.GAA20850@java0.javasoft.com> 
Date: Thu, 25 Jan 1996 21:11:44 -0800
From: Christian Wiedmann <wiedmann@infinity.com>

After studying the source briefly, here's what I think the documentation
of GridBagLayout SHOULD say (in addition to what's already there):

gridwidth, gridheight

  A value of RELATIVE will assign all cells but the last to the current
object.  A value of REMAINDER specifies that the current object will be the
last one on its row/column.  Note: do not use RELATIVE or REMAINDER more than
once each, or else you will squeeze some of your components off your panel.

weightx, weighty

  These values are used to determine how to distribute any extra space or
remove space as the panel is resized.  Each row or column will have space
added or subtracted proportionately to its aggregate weight.  If you have a
component which spans more than one row or column, its weight is distributed
evenly over the rows or columns it spans.
  One handy use of these values is to control the resizing to allocate all
extra space to a given component (very useful for TextAreas at the bottom of
a panel).

This is perhaps not the easiest topic in the world to explain, but for
what it's worth these facts helped me a bunch in using GridBagLayout.  Please
let me know if I didn't get my explanation right.

A word of advice:  keep your weightx's and weighty's simple until you're
sure you need to get fancy.  You can easily sprain your brain working with
them ;-).  I heartily recommend playing with the example to see what
different values do.

Hoping this message won't have been made redundant by a reply I haven't seen
yet,

	-Christian

-
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