[luau] java on linux question - sorry, source inserted
Ray Strode
halfline at hawaii.rr.com
Tue Feb 11 23:49:00 PST 2003
> Uhm, for those people who program in Java on Linux,
I'm not really qualified to answer, because I haven't used Java in
a while and I haven't ever used a GridBagLayout,
but I'm going to guess, and it probably won't be much help you.
All of my speculation is based on guessed semantics from the names
of the classes.
> is there any reason that everything here wouldn't stack up nice and
> clear at least horizontally?
I'm guessing the fill member of the constraints object specifies whether
the given control should
grow to fill any surplus it has in its cell(s). I'm guessing that the
BOTH constant means the
control should grow both horizontally and vertically. I'm guessing
gridwidth is the number of cells
the given control is allocated horizontally (something like colspan in
html). Are my assumptions
correct?
I think that the fact the buttons are different widths are a symptom of
the problem, not the cause.
The grid columns themselves are different widths, and the buttons are
configured to fill the entire
width of their respective columns. I think if you set the fill member
to 0 or NEITHER or NONE or
whatever the constant is called, then the buttons would be the same
width, but the spacing
would look weird. Am I right?
Now here is my completely uniformed guess at what might be going wrong:
I think your problem might actually be the labels. They are probably
going to try to prevent
themselves from wrapping or at least wrapping on non-whitespace as much
as they are able.
So the columns with labels are probably as wide as the labels, which are
probably wider than
the other columns, becuase the other columns contain controls that
handle small space better
(e.g. the text controls scroll and clip, the buttons shrink, etc..).
If what i'm saying is right, then the first and fourth columns probably
have the widest buttons.
Again, though, I want to make it clear to you that I'm just guessing and
have no idea if that is
actually the problem. I don't use Java very much.
Another possible guess: it wants a new contraints object for every add
call, and by passing
the same reference around you are confusing it? I haven't looked at the
documentation, so
I don't know what it expects.
One general note:
> for (int i = 0; i < 5; i++)
> {
> macroFunctionButton[i] = new Button();
> macroFunctionButton[i].setLabel("Function " + i);
> g.gridx = i;
I think it would better, if you moved this down a line and changed it
to g.gridx++....
>
> add(macroFunctionButton[i], g);
> }
>
> g.gridx = 5;
...then this line wouldn't be needed, yes?
--Ray
More information about the LUAU
mailing list