Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Simple GridLayout problem
Simple GridLayout problem [message #448048] Wed, 29 December 2004 03:44 Go to next message
Eclipse UserFriend
Originally posted by: tschlat.gmx.de

Hi

I wondered if somebody could help me with a simple layout problem using
grid layout. I would like to layout two rows. First row: label, text,
button. Second row label, text. I would like the text to take up all
horizontal space. I use the code posted below but the text widget of the
first row does not excess all the space. Instead the button column is too
wide. I do not see what I am doing wrong.
I could probably solve the problem using a different layout but I am
curious to know why my attempt does not work.


Group generalDataGroup = new Group(container, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 3;
layout.verticalSpacing = 9;
layout.makeColumnsEqualWidth = false;
generalDataGroup.setLayout(layout);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan=1;
generalDataGroup.setLayoutData(gd);


// first row
label = new Label(generalDataGroup, SWT.NONE);
label.setText("label1");

Text text = new Text(generalDataGroup, SWT.SINGLE|SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
// if I use this hint everything looks fine:
//gd.widthHint = 400;
text.setLayoutData(gd);

Button button = new Button(generalDataGroup, SWT.PUSH);
button.setText("...");

// second row
label = new Label(generalDataGroup, SWT.NONE);
label.setText("label2");

text = new Text(generalDataGroup, SWT.SINGLE|SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
text.setLayoutData(gd);
Re: Simple GridLayout problem [message #448049 is a reply to message #448048] Wed, 29 December 2004 04:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

your code is good for the first look. Is it possible, to get an screenshot?
It would help, if you give your different Groups an Composites a
backgroundcolor.

But I've seen your code is very complicated. It will be easier for other to
understand your code, if you make it simpler like this.

Group generalDataGroup = new Group(container, SWT.NONE);
layout = new GridLayout(3, false);
layout.verticalSpacing = 9;
generalDataGroup.setLayout(layout);
generalDataGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

// first row
label = new Label(generalDataGroup, SWT.NONE);
label.setText("label1");

Text text = new Text(generalDataGroup, SWT.SINGLE|SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

Button button = new Button(generalDataGroup, SWT.PUSH);
button.setText("...");

// second row
label = new Label(generalDataGroup, SWT.NONE);
label.setText("label2");

text = new Text(generalDataGroup, SWT.SINGLE|SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
text.setLayoutData(gd);

Bye Stefan
(Bis demn
Re: Simple GridLayout problem [message #448074 is a reply to message #448049] Thu, 30 December 2004 10:08 Go to previous message
Eclipse UserFriend
Originally posted by: tschlat.gmx.de

Hi,
after some discussion with Stefan it seems to me, that I ran into a bug in
the SWT. It seems to be solved already. After loading the latest SWT
package from CVS it works.
Thanx to Stefan.

Ciao, Thorsten
Previous Topic:TableViewer not lazy?? :-(
Next Topic:How to programatically set the charSet of a font ?
Goto Forum:
  


Current Time: Wed Jul 23 18:15:01 EDT 2025

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

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

Back to the top