Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 22:30 Go to next message
Richard Kennard is currently offline Richard KennardFriend
Messages: 4
Registered: March 2010
Junior Member
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] Thu, 25 March 2010 01:48 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
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 11:03 Go to previous message
Richard Kennard is currently offline Richard KennardFriend
Messages: 4
Registered: March 2010
Junior Member
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 Aug 18 21:04:42 GMT 2019

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

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

Back to the top