Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layout label and combo in fixed size window
Layout label and combo in fixed size window [message #729540] Mon, 26 September 2011 13:03 Go to next message
arthurav2005 is currently offline arthurav2005Friend
Messages: 10
Registered: August 2011
Junior Member
I want to layout a label and a combo on a single row. The situation is like this:

GridLayout gridLayout = new GridLayout( numColumns,  makeColumnsEqualWidth);

parentComposite.setLayout(gridLayout);

Label label = new Label( parent, SWT.NONE );
label.setText("Label1");
label.setLayoutData( new GridData(SWT.FILL, SWT.DEFAULT, true, false);


Combo combo = new Combo( parent, SWT.NONE );
combo.setLayoutData( new GridData(SWT.FILL, SWT.DEFAULT, true, false);
combo.add("-----------------------------------------------------------------");
combo.select(0);



With a fixed window size, for example 500x300 I expect the label and the combo to layout correctly in the space without any overlap. The problem is in this case the combo takes all the space in order to show as much as possible of the text.

Is there a way to solve this solely with layouts, I mean, without using setPreferredSize?

Thank you.
Re: Layout label and combo in fixed size window [message #729568 is a reply to message #729540] Mon, 26 September 2011 14:24 Go to previous messageGo to next message
Thomas Singer is currently offline Thomas SingerFriend
Messages: 75
Registered: July 2009
Member
You were using Swing before? In SWT there is no setPreferredSize, unfortunately.
Re: Layout label and combo in fixed size window [message #729572 is a reply to message #729568] Mon, 26 September 2011 14:33 Go to previous messageGo to next message
arthurav2005 is currently offline arthurav2005Friend
Messages: 10
Registered: August 2011
Junior Member
No Smile. I have mistakenly reproduced a suggestion from another forum.

I would like to find a solution for the problem using layouts.
Re: Layout label and combo in fixed size window [message #729836 is a reply to message #729572] Tue, 27 September 2011 04:36 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
try this, and u have to specify some minimum width for combo or label
GridLayout gridLayout = new GridLayout( numColumns,  makeColumnsEqualWidth);

parentComposite.setLayout(gridLayout);

Label label = new Label( parent, SWT.NONE );
label.setText("Label1");
GridData labelGridData = new GridData(GridData.FILL_HORIZONTAL);
label.setLayoutData(labelGridData );


Combo combo = new Combo( parent, SWT.NONE );
GridData comboGridData = new GridData(GridData.FILL_HORIZONTAL);
combo.setLayoutData(labelGridData );
combo.add("-----------------------------------------------------------------");
combo.select(0);

//based on which control u want set a minimum width u say
labelGridData.minimumWidth=[your prefered size];
//or
comboGridData.minimumWidth=[your prefered size];


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Layout label and combo in fixed size window [message #729890 is a reply to message #729836] Tue, 27 September 2011 08:28 Go to previous message
arthurav2005 is currently offline arthurav2005Friend
Messages: 10
Registered: August 2011
Junior Member
Thank you very much. Works now.
Previous Topic:Windows 7 Directory Dialog Issues
Next Topic:How to inhibit pasting with button 2 (wheel button) on Linux
Goto Forum:
  


Current Time: Thu Mar 28 20:23:11 GMT 2024

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

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

Back to the top