Dialog layout and resize problem [message #458257] |
Tue, 12 July 2005 08:56  |
Eclipse User |
|
|
|
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 10:35   |
Eclipse User |
|
|
|
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 #458414 is a reply to message #458411] |
Wed, 13 July 2005 05:29   |
Eclipse User |
|
|
|
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 134 times)
|
|
|
|
Powered by
FUDForum. Page generated in 0.03906 seconds