Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » FormLayout aligning to biggest label?
FormLayout aligning to biggest label? [message #466919] Thu, 19 January 2006 12:49 Go to next message
Robert (Kraythe) Simmons is currently offline Robert (Kraythe) SimmonsFriend
Messages: 1
Registered: July 2009
Junior Member
Greetings. I have a panel in which I am using a FormLayout. In that panel
there are 3 labels which are internationalized to run in 2 languages.
Furthermore, each label has a text field next to it in which the user
enters data. In english the top label is the largest horizontally. In
german the middle label is the largestand in french the bottom label is
largest. All labels are right justified. Is there any way I can specify
form attachments to make all of the labels line up on the right side so
that the fields attached the the labels line up? It should work no matter
which one is longest.

For example, this works if I want to line the bottom two to the top one,
but if the bottom or middle label is bigger then they are cut off.


FormData data;
Label a = new Label(...);
data = new FormData();
data.left = new FormAttachment(0,0);
a.setLayoutData(data);

Label b = new Label(...);
data = new FormData();
data.left = new FormAttachment(0,0);
data.right = new FormAttachment(a, 0, SWT.RIGHT);
b.setLayoutData(data);

Label c = new Label(...);
data = new FormData();
data.left = new FormAttachment(0,0);
data.right = new FormAttachment(b, 0, SWT.RIGHT);
c.setLayoutData(data);


I want something like this that will work no matter which label is bigger.

TIA

-- Robert
Re: FormLayout aligning to biggest label? [message #466951 is a reply to message #466919] Thu, 19 January 2006 19:45 Go to previous message
Eclipse UserFriend
Originally posted by: kwpeck.mersoft.com

I would suggest using GridLayout instead of FormLayout. If you set the
GridLayout for two columns and set equal column widths to false you will
get what you want.

You don't have to do the ENTIRE panels layout as a GridLayout. You can
do a simple composite that holds the labels you describe below in a
GridLayout and add that composite to the overall FormLayout where you
want it to appear.

With out a bunch of fancy pants coding you are not going to achieve what
you want with FormLayout.

Robert Simmons Jr. wrote:
> Greetings. I have a panel in which I am using a FormLayout. In that
> panel there are 3 labels which are internationalized to run in 2
> languages. Furthermore, each label has a text field next to it in which
> the user enters data. In english the top label is the largest
> horizontally. In german the middle label is the largestand in french the
> bottom label is largest. All labels are right justified. Is there any
> way I can specify form attachments to make all of the labels line up on
> the right side so that the fields attached the the labels line up? It
> should work no matter which one is longest.
> For example, this works if I want to line the bottom two to the top one,
> but if the bottom or middle label is bigger then they are cut off.
>
> FormData data; Label a = new Label(...);
> data = new FormData();
> data.left = new FormAttachment(0,0);
> a.setLayoutData(data);
>
> Label b = new Label(...);
> data = new FormData();
> data.left = new FormAttachment(0,0);
> data.right = new FormAttachment(a, 0, SWT.RIGHT);
> b.setLayoutData(data);
>
> Label c = new Label(...);
> data = new FormData();
> data.left = new FormAttachment(0,0);
> data.right = new FormAttachment(b, 0, SWT.RIGHT);
> c.setLayoutData(data);
>
>
> I want something like this that will work no matter which label is bigger.
> TIA
>
> -- Robert
>
Previous Topic:Text on a GC
Next Topic:Buttons stay when window is maximized
Goto Forum:
  


Current Time: Fri Nov 22 12:31:23 GMT 2019

Powered by FUDForum. Page generated in 0.01585 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top