Current position:  Home > Default > Boxlayout - align things to the right?

Boxlayout - align things to the right?

Time:November 30
Advertisement
Hi all,
I have a Box setup with PAGE_AXIS layout.. The Box will contain several JLabel icons (no text) and will be wider than the icons combines. I want the extra space to appear on the left side instead of the right. How do I add this?
I've tried adding Box.createHorizontaGlue() as the first thing but that doesnt help.
FYI, this container will implement TableCellRenderer
So like this:
[ .........................[  ] [  ][  ][  ][  ][  ][  ]|
-------------------------------------------
Advertisement
As already mentioned in a boxLayout you have to set the alignment of each child to get the overall alignment. While that's acceptable in a small container, it can get boring in a bigger environment. So in the long run you might consider switching to more powerful LayoutManager like JGoodies FormLayout (http://forms.dev.java.net/): it lets you define component alignment on a per-column/row basis.
Personally I switched completely to FormLayout (from nested BoxLayouts which are not too bad, IMO) and developed a visual builder for it (http://swingempire.de/palace/FormBuilder) <g>
Greetings
Jeanette