|
Replies:
4
-
Last Post:
Oct 8, 2008 10:27 PM
by: cknappe
|
|
|
|
|
|
|
Layout Question
Posted:
Oct 8, 2008 6:12 AM
|
|
|
Hello,
is it possible to set the alignment of a container? I have to build a BorderLayout. At the south of this layout there have to be 2 buttons. If I add those buttons to the BorderLayout just the last added is displayed. OK - so I put them into a FlowLayout Container and add this to the South of the BorderLayout. The Problem now is, that this Container (in which the buttons are) is always at the left side. Can I do something like container.setAlignment(Center)?
Regards, Christian
|
|
|
|
|
|
|
Re: Layout Question
Posted:
Oct 8, 2008 7:41 AM
in response to: cknappe
|
 |
Helpful |
|
|
Hi,
try using GridLayout instead of FlowLayout. Or maybe using another BorderLayout with one button at east and the other at the west.
Regards
|
|
|
|
|
|
|
|
Re: Layout Question
Posted:
Oct 8, 2008 10:59 AM
in response to: cknappe
|
 |
Helpful |
|
|
I have always used FlowLayout for centering buttons. I have been away from Swing (unfortunately) for about a year now, but I have just thrown together a quick prototype that has a frame (with BorderLayout) that contains a Panel (with FlowLayout) in the South region. The Panel contains two buttons, and they are centered.
If you are looking more for configuring the button placement (one centered, and one right-justified), I would use X-Axis BoxLayout (making use of Box.createHorizontalGlue() and Box.createHorizontalStrut() to help with positioning) instead of FlowLayout.
Hope that helps
I entered your post directly from the java.net page and didn't realize it was for LWUIT thread. Not sure what API is available there, so my comments may not be relevant - sorry.
Message was edited by: tborak
|
|
|
|
|
|
|
|
Re: Layout Question
Posted:
Oct 8, 2008 11:59 AM
in response to: cknappe
|
|
|
|
|
Hi, some layouts support this others don't. I think flow layout supports center alignment. You can also nest border layouts etc.
There is also this: http://lwuit.blogspot.com/2008/07/as-you-like-it-layouts-any-way-you- want.html
> Hello, > > is it possible to set the alignment of a container? I have to build > a BorderLayout. At the south of this layout there have to be 2 > buttons. If I add those buttons to the BorderLayout just the last > added is displayed. OK - so I put them into a FlowLayout Container > and add this to the South of the BorderLayout. The Problem now is, > that this Container (in which the buttons are) is always at the > left side. Can I do something like container.setAlignment(Center)? > > Regards, > Christian > [Message sent by forum member 'cknappe' (cknappe)] > > http://forums.java.net/jive/thread.jspa?messageID=303952 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net > For additional commands, e-mail: users-help@lwuit.dev.java.net >
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
Re: Layout Question
Posted:
Oct 8, 2008 10:27 PM
in response to: cknappe
|
|
|
Hi all of you,
thank you all for your fast replies. Now it works - I just had to construct the FlowLayout as new FlowLayout(Container.CENTER) - that's it . FlowLayout supports center alignment as Shai mentioned.
Thank you.
Regards, Christian
|
|
|
|
|