Layout label and combo in fixed size window [message #729540] |
Mon, 26 September 2011 13:03 |
arthurav2005 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 #729836 is a reply to message #729572] |
Tue, 27 September 2011 04:36 |
Vijay Raj 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03369 seconds