Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » GridLayout has forced margin but FillLayout does not?
GridLayout has forced margin but FillLayout does not? [message #523062] Wed, 24 March 2010 18:30 Go to next message
Eclipse UserFriend
Hi guys,

I'm trying to layout some nested Composites on a Windows platform. It's hard to get the alignment right because it appears GridLayout has some kind of 'implicit margin'. FillLayout has no such margin.

For example, the code...

	public static void main( String[] args )
	{
		Display display = new Display();
		Shell shell = new Shell( display, SWT.DIALOG_TRIM | SWT.RESIZE );
		shell.setLayout( new FillLayout() );

		Composite composite1 = new Composite( shell, SWT.BORDER );
		composite1.setLayout( new FillLayout() );
		Composite composite2 = new Composite( composite1, SWT.BORDER );
		composite2.setLayout( new GridLayout( 1, false ) );
		Composite composite3 = new Composite( composite2, SWT.BORDER );
		composite3.setLayout( new FillLayout() );
		Composite composite4 = new Composite( composite3, SWT.BORDER );

		shell.setVisible( true );
		shell.open();

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

		display.dispose();
	}


...produces...

http://metawidget.org/experimental/margin.png

You can see that the FillLayouts are nested very close to each other, while the GridLayout has a gap of about 5 pixels at its left/top.

Is there any way to remove this implicit margin? I have tried setting marginLeft and/or horizontalSpacing to 0, but that seems to have no effect.

Thanks,

Richard.
Re: GridLayout has forced margin but FillLayout does not? [message #523106 is a reply to message #523062] Wed, 24 March 2010 21:48 Go to previous messageGo to next message
Eclipse UserFriend
On 25/03/10 4:00 AM, Richard Kennard wrote:

> Is there any way to remove this implicit margin? I have tried setting
> marginLeft and/or horizontalSpacing to 0, but that seems to have no effect.


The default value for FillLayout.marginWidth and
FillLayout.marginHeight is 0 and for GridLayout.marginWidth and
GridLayout.marginHeight is 5. Set the fields to 0 and that margin should
be gone.

- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: GridLayout has forced margin but FillLayout does not? [message #523151 is a reply to message #523062] Thu, 25 March 2010 07:03 Go to previous message
Eclipse UserFriend
Awesome. Worked great. Thank you so much.

Richard.
Previous Topic:SWT browser inside Swing panel
Next Topic:Experienced Win SWT team porting to OSX
Goto Forum:
  


Current Time: Sun Jul 27 05:08:34 EDT 2025

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

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

Back to the top