> Huh? I've never seen that behavior before. GBL's a pain to use, but
>it's always been very reliable. Can you post some sample code?
Roedy Green <roedy@seewebsite.com>
wrote on Mon, 03 Nov 2003 01:25:49 GMT:
>> Huh? I've never seen that behavior before. GBL's a pain to use, but
>>it's always been very reliable. Can you post some sample code?
> To see the sort of layout I am talking about layout click
> http://mindprod.com/replicator/replicatorwebsite.html
404, and the directory contains no source code. I don't want to see
your whole app, anyway, just the GUI parts.
> There are variants on it with more fields. The catch is the proportion
> of space to the left and right of the centreline changes when you add
> more fields.
Without seeing the code, I can't tell you exactly what you're doing
wrong, but it's almost certainly a result of incorrect values in your
GridBagConstraints. If you take a look at the Javadocs for GBC and GBL,
it's pretty clear.
For a start, only use gbc.anchor=gbc.NORTHWEST (the default CENTER is
usually more attractive, but it's probably misleading you as to where a
cell starts), set gridx, gridy to your cell (I don't recommend using the
default RELATIVE until you know what that does), and use the default
values (listed in the Javadoc) for other fields, until you get the
basics down right. Maybe use gridwidth, gridheight if you have to do a
colspan/rowspan kind of thing.
> There are two sorts of answer to this question:
> 1. stand on one leg on a full moon, put your finger up your nose, cut
[quoted text clipped - 3 lines]
> What we have acts like a Louisiana lawyer trying to wriggle out of
> doing what I want. There has to be a better way!
Both of those answers are completely wrong, falsely blaming the tools
rather than the workman. The third sort of answer, the correct one, is
"RTFM".
It's a moderately complicated tool, but that's because layout is a
complicated problem. It does *everything*, and its behavior is
rigorously correct and consistent, in my long experience with it; every
time I've had a problem with it, I've always kicked myself for being an
idiot when I realize what I did wrong. If all else fails, you have the
JDK source like everyone else. Read it.
The fourth meta-answer is, it's not hard to write layout managers. If
you're dissatisfied with GBL, write your own and use that. A layout
that takes a Rectangle of grid coords as the constraints, and does not
resize its components, would be easy enough to write.

Signature
<a href="http://kuoi.asui.uidaho.edu/~kamikaze/"> Mark Hughes </a>
"I believe in communication. If I communicate with you every so often,
you'll be bothered by what I say enough that you won't ask me to, which
means more sleep for me." -Something Positive, 2003Sep22