Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Dialog layout and resize problem
Dialog layout and resize problem [message #458257] Tue, 12 July 2005 12:56 Go to next message
Eclipse UserFriend
Originally posted by: taavi.tanavsuu.ee.ibm.com

Hi,

I have a resizable dialog (extending org.eclipse.jface.dialogs.Dialog)
that contains several input values. Here's a part of the code:

===================
...

//Create composite
Composite composite = ... ; //creates a composite for fields in the
dialog.
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
composite.setLayout(layout);

//Create labels and fields:
Label nameLabel = new Label(composite,SWT.NONE);
nameLabel.setText("Name:");
nameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label linkLabel = new Label(composite,SWT.NONE);
linkLabel.setText("Link:");
linkText = new Text(composite, SWT.SINGLE | SWT.BORDER);
linkText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

...
====================

Problem is that when a user makes the dialog wider, both columns of the
layout get wider, i.e. excess empty space between the end of the labels
and beginning of the fields grows as well. How to make only the second
column (the fields column), get wider, and the width of the first coulmn
(the labels column) always stay the same? I haven't so far figured that
out...

Thanks in advance :)

-taavi
Re: Dialog layout and resize problem [message #458271 is a reply to message #458257] Tue, 12 July 2005 14:35 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

Use GridData.GRAB_HORIZONTAL style bit for the second column

Regards,
Boby


<taavi.tanavsuu@ee.ibm.com> wrote in message
news:db0ekv$5km$1@news.eclipse.org...
> Hi,
>
> I have a resizable dialog (extending org.eclipse.jface.dialogs.Dialog)
> that contains several input values. Here's a part of the code:
>
> ===================
> ..
>
> //Create composite
> Composite composite = ... ; //creates a composite for fields in the
> dialog.
> GridLayout layout = new GridLayout();
> layout.numColumns = 2;
> layout.makeColumnsEqualWidth = false;
> composite.setLayout(layout);
>
> //Create labels and fields:
> Label nameLabel = new Label(composite,SWT.NONE);
> nameLabel.setText("Name:");
> nameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
> nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
> Label linkLabel = new Label(composite,SWT.NONE);
> linkLabel.setText("Link:");
> linkText = new Text(composite, SWT.SINGLE | SWT.BORDER);
> linkText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
>
> ..
> ====================
>
> Problem is that when a user makes the dialog wider, both columns of the
> layout get wider, i.e. excess empty space between the end of the labels
> and beginning of the fields grows as well. How to make only the second
> column (the fields column), get wider, and the width of the first coulmn
> (the labels column) always stay the same? I haven't so far figured that
> out...
>
> Thanks in advance :)
>
> -taavi
Re: Dialog layout and resize problem [message #458411 is a reply to message #458271] Wed, 13 July 2005 06:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: taavi.tanavsuu.ee.ibm.com

Hi,

Seems to not work, the GridData.FILL_HORIZONTAL i'm using is actually
HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL.

-taavi

> Hi,
>
> Use GridData.GRAB_HORIZONTAL style bit for the second column
>
> Regards,
> Boby
Re: Dialog layout and resize problem [message #458412 is a reply to message #458257] Wed, 13 July 2005 07:18 Go to previous messageGo to next message
Daniel Hirscher is currently offline Daniel HirscherFriend
Messages: 43
Registered: July 2009
Member
Taavi,

set empty griddatas on the labels.

> ===================
> ..
>
> //Create composite
> Composite composite = ... ; //creates a composite for fields in the
> dialog.
> GridLayout layout = new GridLayout();
> layout.numColumns = 2;
> layout.makeColumnsEqualWidth = false;
> composite.setLayout(layout);
>
> //Create labels and fields:
> Label nameLabel = new Label(composite,SWT.NONE);
> nameLabel.setText("Name:");
nameLabel.setLayoutData(new GridData());
> nameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
> nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
> Label linkLabel = new Label(composite,SWT.NONE);
> linkLabel.setText("Link:");
linkLabel.setLayoutData(new GridData());
> linkText = new Text(composite, SWT.SINGLE | SWT.BORDER);
> linkText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

Daniel
Re: Dialog layout and resize problem [message #458414 is a reply to message #458411] Wed, 13 July 2005 09:29 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Yes, you're right, I forgot that.
I made a simple snippet and it's working with SWT version 3.063.

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

/**
* @author Robert Bacs
*/
public class ShellTest {
public static void main (String [] args) {
final Display display = new Display ();
final Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
Composite c = new Composite(shell, SWT.NONE);
c.setLayout(new GridLayout(2, false));
Label nameLabel = new Label(c, SWT.NONE);
nameLabel.setText("Name:");
Text nameText = new Text(c, SWT.SINGLE | SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
nameText.setLayoutData(gd);
Label linkLabel = new Label(c, SWT.NONE);
linkLabel.setText("Link:");
Text linkText = new Text(c, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
linkText.setLayoutData(gd);

shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}


<taavi.tanavsuu@ee.ibm.com> wrote in message
news:db2b4q$aqg$1@news.eclipse.org...
> Hi,
>
> Seems to not work, the GridData.FILL_HORIZONTAL i'm using is actually
> HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL.
>
> -taavi
>
> > Hi,
> >
> > Use GridData.GRAB_HORIZONTAL style bit for the second column
> >
> > Regards,
> > Boby


  • Attachment: images.zip
    (Size: 7.31KB, Downloaded 115 times)
Re: Dialog layout and resize problem [message #458473 is a reply to message #458412] Thu, 14 July 2005 08:13 Go to previous message
Eclipse UserFriend
Originally posted by: taavi.tanavsuu.ee.ibm.com

Hi,

> set empty griddatas on the labels.

Doesn't work either ... :(

-taavi
Previous Topic:Browser Widget execute() Acrobat Reader 7 - exception thrown
Next Topic:Does CCombo have a ComboViewer designed to work with it? (no text)
Goto Forum:
  


Current Time: Tue Apr 16 13:34:49 GMT 2024

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

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

Back to the top