Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Filllayout
SWT Filllayout [message #716892] Thu, 18 August 2011 17:34 Go to next message
Balaji  is currently offline Balaji
Messages: 17
Registered: August 2011
Junior Member
Hi
When I am using FillLayout(Vertical), the controls are been placed with equal spacing.

But I want to place the control with different spacing. ie. Control-1 should occupy 90% of Composite and Control-2 has to be placed in next 10%.

(If FillLayout wont work, please let me know the other Layout also)
Re: SWT Filllayout [message #717008 is a reply to message #716892] Fri, 19 August 2011 04:25 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
use GridLayout with 10 columns and give control 1 Griddata(Griddata.FILL_BOTH) with a horizontal span of 9 and control 2 with Griddata(Griddata.FILL_BOTH) single span.

something like this
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class SWTGridExample{

	public SWTGridExample() {

		Display d = new Display();
		Shell s = new Shell(d);
		s.setLayout(new GridLayout(10, true));
		Text t1 = new Text(s, SWT.BORDER);
		GridData layoutData = new GridData(GridData.FILL_BOTH);
		layoutData.horizontalSpan = 9;		
		t1.setLayoutData(layoutData);
		Text t2 = new Text(s, SWT.BORDER);
		t2.setLayoutData(new GridData(GridData.FILL_BOTH));
		s.open();
		while (!s.isDisposed()) {
			if (!d.readAndDispatch())
				d.sleep();
		}
		d.dispose();
	}

	public static void main(String[] argv) {

		new SWTGridExample();

	}

}


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: SWT Filllayout [message #717035 is a reply to message #717008] Fri, 19 August 2011 06:41 Go to previous messageGo to next message
Balaji  is currently offline Balaji
Messages: 17
Registered: August 2011
Junior Member
Hi Thanks again.

Its working fine. Initially I thought it will help me but that doesnt fullfill my requirement.

My Requirement is.

My form will have 2 controls. In that control-2 should occupy height of 10px (approx).
Where control-1 should occupy rest. So even while resizing window, CONTROL-2 will be of same height where CONTROL-1 will be resized
Re: SWT Filllayout [message #717047 is a reply to message #717035] Fri, 19 August 2011 07:08 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
same Gridlayout but with single column and control 2 griddata will have a height hint of 10 and control 1 will have Griddata(Griddata.FILL_HORIZONTAL) and verticalAlignment=SWT.BOTTOM.

you have to explore different paramaters of the griddata to play around...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: SWT Filllayout [message #717078 is a reply to message #717047] Fri, 19 August 2011 08:32 Go to previous messageGo to next message
Balaji  is currently offline Balaji
Messages: 17
Registered: August 2011
Junior Member
Thanks Smile
Re: SWT Filllayout [message #717108 is a reply to message #717078] Fri, 19 August 2011 10:52 Go to previous message
Lakshmi Shanmugam
Messages: 274
Registered: July 2009
Location: India
Senior Member
Also see this article on understanding the different layouts --> http://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html

Lakshmi P Shanmugam
Previous Topic:Canvas to Image
Next Topic:Canvas SetBackgroundImage
Goto Forum:
  


Current Time: Thu Oct 02 04:32:21 GMT 2014

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

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