Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Width of compound widget
Width of compound widget [message #447744] Thu, 16 December 2004 20:57
Thorsten is currently offline ThorstenFriend
Messages: 5
Registered: July 2009
Junior Member
Hi,

I have created a compound widget which consists of a Combo and a Button. I
would like to layout this compound together with other Combos (vertically)
unfortunately neither the left edge of the Combo fits the left edge of the
Combo above nor the right edge of the Button fits the right edge of the
Combo above. It looks like this:

--------------------
Label | combo |
--------------------
------------- ----
Label | combo | |BT|
------------- ----

Here is the code that creates the compound widget:

Initialisation of compound widget (CountrySelector):

private void init(Composite parent) {
GridLayout layout= new GridLayout(2, false);
this.setLayout(layout);

GridData gd= new GridData(GridData.FILL_HORIZONTAL |
GridData.GRAB_HORIZONTAL);
countryName = new Combo(this, SWT.SINGLE | SWT.BORDER);
countryName.setLayoutData(gd);

gd= new GridData();
gd.heightHint = countryName.computeSize(SWT.DEFAULT, SWT.DEFAULT,
false).y;
searchButton = new Button(this, SWT.PUSH);
searchButton.setText("...");
searchButton.setLayoutData(gd);
}

Here is the code that creates the control in a SearchPage:
public void createControl(Composite parent) {
initializeDialogUnits(parent);

GridData gd;
Composite result= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout(2, false);
result.setLayout(layout);
Label label= new Label(result, SWT.LEFT);

label.setText(SearchMessages.getString("SearchPage.containingText.text "));

gd= new GridData(GridData.BEGINNING);
gd.horizontalSpan= 1;
label.setLayoutData(gd);

Combo combo = new Combo(result, SWT.SINGLE | SWT.BORDER);;
gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan= 1;
combo.setLayoutData(gd);

label= new Label(result, SWT.LEFT);

label.setText(SearchMessages.getString("SearchPage.containingText.text "));
gd= new GridData(GridData.BEGINNING);
gd.horizontalSpan= 1;
label.setLayoutData(gd);

CountrySelector countrySelector = new CountrySelector(result, SWT.NONE);;
gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan= 1;
countrySelector.setLayoutData(gd);
setControl(result);
Dialog.applyDialogFont(result);
}

I have no experience with SWT since I am usually programming Swing but it
seems to me that the Composite that makes up the compound also uses a
border or trim or whatever. I have studied the article "Creating Your Own
Widgets using SWT" but I don't really see how to solve this problem. Help
would be appreciated.

Thanx in advance
Thorsten
Previous Topic:[POCKET PC] SWT exception when creating tree
Next Topic:Button lost XP appearance
Goto Forum:
  


Current Time: Fri May 10 03:28:39 GMT 2024

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

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

Back to the top