Skip to main content



      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 09:03 Go to next message
Eclipse UserFriend
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 10:24 Go to previous messageGo to next message
Eclipse UserFriend
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 10:33 Go to previous messageGo to next message
Eclipse UserFriend
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 00:36 Go to previous messageGo to next message
Eclipse UserFriend
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];
Re: Layout label and combo in fixed size window [message #729890 is a reply to message #729836] Tue, 27 September 2011 04:28 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 14:37:43 EDT 2025

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

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

Back to the top