|
Re: Layout: align buttons vertical - center [message #451383 is a reply to message #451328] |
Mon, 28 February 2005 19:39 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
Use a GridLayout or a FormLayout. E.g.:
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout());
Composite parent = new Composite(shell, SWT.BORDER);
parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
parent.setLayout(new GridLayout());
Button b = new Button(parent, SWT.PUSH);
b.setText("button1");
b.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
b = new Button(parent, SWT.PUSH);
b.setText("button2");
b.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
b = new Button(parent, SWT.PUSH);
b.setText("button3");
b.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
b = new Button(parent, SWT.PUSH);
b.setText("button4");
b.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
"Pieter Vunckx" <swt@anderlecht-online.be> wrote in message
news:cvod21$tqc$1@www.eclipse.org...
> Hi,
>
> I've a layout-problem ...
>
> How can I align a few (4) buttons vertical in the center of a window ?
> With on both sides "white" space ...
> (Paint example: http://users.pandora.be/vunckx/layout.jpg )
>
> I hope you understand my question :-)
>
> Thx in advance,
>
> Pieter
>
|
|
|
Powered by
FUDForum. Page generated in 0.03467 seconds