Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » grid layout problems
grid layout problems [message #461865] Mon, 03 October 2005 19:35 Go to next message
Darren Beaumont is currently offline Darren BeaumontFriend
Messages: 3
Registered: July 2009
Junior Member
In the createComposite() of a WizardPage, I have a composite which has a
grid layout with 2 columns. I use the following code to set 2 columns, the
left of labels and the right textboxes. I want the textboxes to grab the
excess horizontal space.

GridData data = new GridData(GridData.FILL_HORIZONTAL);
for (int i = 0; i < label.length; i++)
{
label[i] = new Label(composite, SWT.NONE);
label[i].setText("");
text[i] = new Text(composite, SWT.BORDER);
text[i].setLayoutData(data);
}

The previous page calls an initialize procedure for the WizardPage
to setText for label[]. The text varies dependant on values chosen in the
previous page.

The problem occurs when you run the wizard and show the page. The page
shows the textboxes filling the whole width of the composite (since the
labels were initially ""). A closer look at the code showed me that the
labels had changed their text, but i suspect the page layout is not
refreshing to widen the column and show the labels text.

Any ideas to solve this problem?

Regards, Darren
Re: grid layout problems [message #462055 is a reply to message #461865] Wed, 05 October 2005 12:54 Go to previous message
Eclipse UserFriend
Originally posted by: ddana78ar.yahoo.com.ar

> GridData data = new GridData(GridData.FILL_HORIZONTAL);
> for (int i = 0; i < label.length; i++)
> {
> label[i] = new Label(composite, SWT.NONE);
> label[i].setText("");
> text[i] = new Text(composite, SWT.BORDER);
> text[i].setLayoutData(data);
> }

Hi Darren:

you are creating only one object of GridData, you must create a new object of this class for each widget you want to set the layoutData. So, you can do that:

GridData data;
...
for (int i = 0; i < label.length; i++) {
data = new GridData();//or the style what you want
label[i] = new Label(composite, SWT.NONE);
label[i].setText("");
label.setLayoutData(data);

data = new GridData(GridData.FILL_HORIZONTAL);
text[i] = new Text(composite, SWT.BORDER);
text[i].setLayoutData(data);
}

you can see this link:
http://www.eclipse.org/articles/Understanding%20Layouts/Unde rstanding%20Layouts.htm

best regards.
Previous Topic:SWT Java Web Launch through jnlp for MAC
Next Topic:Control to keep Text and Image
Goto Forum:
  


Current Time: Fri Apr 26 03:27:37 GMT 2024

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

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

Back to the top