>> If I have this layout with 3 columns:
>>
[quoted text clipped - 63 lines]
> the width of comp4 is the width of the 3 columns of the grid and the
> width of comp5 is the width of the first two columns.
Hi, cheers for the reply, on the sun site, in the gridbaglayout tutorial,
http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html, it
says:
"For each column, the weight is related to the highest weightx specified for
a component within that column, with each multicolumn component's weight
being split somehow between the columns the component is in. Similarly, each
row's weight is related to the highest weighty specified for a component
within that row."
That's why I though the weight for col 1 would be 1.0 as comp 4 has a weight
of 1.0 and it is in col 1 (although it's also in column 2 and 3 as well).
It's the "split somehow" bit I don't like!
Monique Y. Mudama - 06 Feb 2006 17:53 GMT
> Hi, cheers for the reply, on the sun site, in the gridbaglayout
> tutorial,
[quoted text clipped - 10 lines]
> a weight of 1.0 and it is in col 1 (although it's also in column 2
> and 3 as well). It's the "split somehow" bit I don't like!
I agree. I've been struggling with GBC.weight lately, too. A
coworker suggested that I only use weights of 0 and 1 so that I
wouldn't drive myself nuts.

Signature
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
A. Bolmarcich - 06 Feb 2006 20:45 GMT
>>> If I have this layout with 3 columns:
>>>
[quoted text clipped - 4 lines]
>>> What would be the effective weight of each column?
>>> Docs say the max in each so would that be:
[snip]
>> With the version of Java that I use, the column weights would be: 0.0,
>> 3.0, 4.0. What docs "say the max in each"? You can run a small program
>> like the following to determine the actual column weights.
[snip]
> Hi, cheers for the reply, on the sun site, in the gridbaglayout tutorial,
> http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html, it
[quoted text clipped - 9 lines]
> of 1.0 and it is in col 1 (although it's also in column 2 and 3 as well).
> It's the "split somehow" bit I don't like!
By using phrases like "is related" and "split somehow", the description
on the Sun web site is correct while being insufficiently detailed to
be able to determine the actual column weights.
The only sufficiently detailed description of GridBagLayout that I know
is the Java source code. The code processes the components in order by
their gridwidths. With your example, after processing the components
with a gridwidth of 1, the column weights are: 0, 3, and 4 (the maximum
of the weight of the component in each column).
Processing the component with a gridwidth of 2 does not change the
column weights because the weight of the component (0.75) is less than
the sum of the previously determined weights of the columns it is in
(0+3).
Processing the component with a gridwidth of 3 does not change the
column weights because the weight of the component (1) is less than
the sum of the previously determined weights of the columns it is in
(0+3+4).
When the weight of a component is greater than the previously
determined weights of the columns it is in, the additional weight is
distributed among the columns in proportion to the previously
determined weights of the columns. If the previously determined
weights are all zero, the additional weight is added to the last column
occupied by the component.
Big Jim - 06 Feb 2006 22:44 GMT
>>>> If I have this layout with 3 columns:
>>>>
[quoted text clipped - 52 lines]
> weights are all zero, the additional weight is added to the last column
> occupied by the component.
thanks a lot, that's a good description, I'm going to pass this on to Roedy
Green to see if he'd like to include it in his Java info pages.
Cheers, Richard.
Monique Y. Mudama - 06 Feb 2006 22:53 GMT
>> The only sufficiently detailed description of GridBagLayout that I
>> know is the Java source code. The code processes the components in
>> order by their gridwidths. With your example, after processing the
>> components with a gridwidth of 1, the column weights are: 0, 3, and
>> 4 (the maximum of the weight of the component in each column).
[snip]
> thanks a lot, that's a good description, I'm going to pass this on
> to Roedy Green to see if he'd like to include it in his Java info
> pages.
>
> Cheers, Richard.
The problem is that anything not published in the documents is likely
to change. In fact, I suspect that is why the explanation of weights
is so vague -- to allow the possibility that their computation will
change.

Signature
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Big Jim - 07 Feb 2006 18:50 GMT
>>> The only sufficiently detailed description of GridBagLayout that I
>>> know is the Java source code. The code processes the components in
[quoted text clipped - 14 lines]
> is so vague -- to allow the possibility that their computation will
> change.
good point!