I have a GUI consisting of three areas:

   ___ ___
  |   | B |
  | A |---|
  |   | C |
  |___|___|

* Area A contains a JTree inside a JScrollPane.

* Area B contains a JTextField, a JButton, and 3 JRadioButtons.

* Area C contains a JSplitPane, which in turn contains a JList within
  a JScrollPane in the top pane, and a JTree within a JScrollPane in
  the bottom pane.

All three areas are laid out within the global container using a
GridBagLayout.  In all cases the fill constraint is set to BOTH.

Initially, the JTextField in B, and the JList and JTree in C are
empty.  Only A has a visible content (unless we count the buttons in
B).  Both panes in C's JSplitPane become populated in response to
actions by the user.

The sizes of contents of A, B, and C should change IF and only if the
user resizes the enclosing frame.  When this happens, the *relative*
widths of A, B, and C should remain constant, and likewise, for the
*relative* heights of A, B, and C.

This should be straightforward (just set all the weight constraints to
a common value, say, 0.5, right?), but nothing is ever straightforward
with the GridBagLayout.  When my GUI is resized, A, B, and C change
sizes (or don't) in ways too polymorphically perverse to describe
briefly.

For example, if the enclosing frame is resized such that only its
height is reduced, A's *width* shrinks.  Even more inexplicably, A's
width also *shrinks* when the enclosing frame is made *wider*.  (It
also shrinks, but disproportionately so, when the width of the
enclosing frame in made smaller.)  When either the height, or both
the height and width of the enclosing frame is increased, A's and B's
heights and width's grow appropriately, but C's height (i.e. the
height of its contents) does not change.  Instead of expanding, C's
contents become surrounded by padding.

How do I get this GUI to behave correctly?

Thanks,

KJ


_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to