The Source for Java Technology Collaboration

Home » java.net Forums » Mobile & Embedded » LWUIT

Thread: Layout Question

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 0. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 4 - Last Post: Oct 8, 2008 10:27 PM by: cknappe
cknappe

Posts: 51
Layout Question
Posted: Oct 8, 2008 6:12 AM
 
  Click to reply to this thread Reply

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

kawaiimomo

Posts: 247
Re: Layout Question
Posted: Oct 8, 2008 7:41 AM   in response to: cknappe
Helpful
  Click to reply to this thread Reply

Hi,

try using GridLayout instead of FlowLayout. Or maybe using another BorderLayout with one button at east and the other at the west.

Regards

tborak

Posts: 8
Re: Layout Question
Posted: Oct 8, 2008 10:59 AM   in response to: cknappe
Helpful
  Click to reply to this thread Reply

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

Shai Almog
Re: Layout Question
Posted: Oct 8, 2008 11:59 AM   in response to: cknappe
  Click to reply to this thread Reply

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]


cknappe

Posts: 51
Re: Layout Question
Posted: Oct 8, 2008 10:27 PM   in response to: cknappe
 
  Click to reply to this thread Reply

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




 XML java.net RSS