A new Swixml version has been released and is available for download at the
Swixml Web site at http://www.swixml.org
0.78 included bug fixes and accepts more GridBag layout parameters.
As you probably have noticed by now, if you don't bring your own, you will
end up using the Swing built-in GridBag Layout Manager a lot.
One of the strange things with this Layout Mgr. is that weightx and weighty
can be assigned to any component when inserting it into the layout. However,
those attributes should only be set once for each row and each column.
Therefore weightx, weighty, (like with and height) are much more Layout
attributes than component attributes.
No wonder that the GridbagLayout has array member like these:
double[] columnWeights : This field holds the overrides to the column
weights.
double[] rowWeights : This field holds the overrides to the row weights.
int[] columnWidths : This field holds the overrides to the column minimum
width.
int[] rowHeights : This field holds the overrides to the row minimum
heights.
When setting up a gridbag layout in the XML descriptor, you may now provide
one (but only one) of those arrays:
Examples:
* GridBagLayout()
* GridBagLayout(rowWeights(0,0,1.0,0))
* GridBagLayout(columnWeights (0.5, 0.5, 1.0, 99.9))
* GridBagLayout(columnWidths(5, 5, 10, 33))
* GridBagLayout(rowHeights(5, 5, 10, 33))
Paired with the GridBagConstraints constants REMAINDER and RELATIVE, this
can leap to simpler and much more maintainable gridbagconstraint tags.
Please see the javadoc for the LayoutConverter for details:
http://www.swixml.org/apidocs/org/swixml/converters/LayoutConverter.html
Real World Example:
<panel border="TitledBorder(Form Access)"
Layout="GridBagLayout(columnWeights(0,1,0))">
<buttongroup>
<radiobutton ActionCommand="Anonymous" Action="selectAction">Anonymous
<gridbagconstraints id="gbc0" gridwidth="1" insets="0,6,0,6"
anchor="GridBagConstraints.NORTHWEST"/>
</radiobutton>
<label>Allow public access.
<gridbagconstraints id="gbc1" insets="0,6,0,6"
anchor="GridBagConstraints.WEST" gridwidth="GridBagConstraints.REMAINDER"/>
</label>
<radiobutton id="rb_Everyone" ActionCommand="Everyone"
Action="selectAction">Everyone
<gridbagconstraints use="gbc0"/>
</radiobutton>
<label>Allow access to all users.
<gridbagconstraints use="gbc1"/>
</label>
<radiobutton ActionCommand="Custom" Action="selectAction">Custom
<gridbagconstraints use="gbc0"/>
</radiobutton>
<label>Allow access to selected users.
<gridbagconstraints use="gbc1"/>
</label>
</buttongroup>
// ...
--
Wolf Paulus
C a r l s b a d C u b e s
mailto:[EMAIL PROTECTED]
CONFIDENTIALITY NOTICE:
This message is intended only for the use of the individual or entity to
which it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, please contact the sender by reply
email and destroy all copies of the original message.