Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layout: align buttons vertical - center
Layout: align buttons vertical - center [message #451328] Fri, 25 February 2005 23:40 Go to next message
Eclipse UserFriend
Originally posted by: swt.anderlecht-online.be

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
Re: Layout: align buttons vertical - center [message #451383 is a reply to message #451328] Mon, 28 February 2005 19:39 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
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
>
Previous Topic:Image and Text in SWT Button
Next Topic:Dynamic Editor Master Detail Parts
Goto Forum:
  


Current Time: Wed Sep 23 03:38:57 GMT 2020

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

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

Back to the top