[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Mixing Fixed Positioning and Layout

Hi,

Maybe I'm completely wrong but take the following snippet of code:

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class Test {
	public static void main(String args[]) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		
		Composite comp = new Composite(shell,SWT.NONE);
		Label l = new Label( comp, SWT.BORDER );
		l.setLocation(new Point(10,10));
		l.setSize(new Point(100,20));
		
		l = new Label( comp, SWT.BORDER );
		l.setLocation(new Point(110,10));
		l.setSize(new Point(100,20));
		
		Composite innerComp = new Composite(comp,SWT.NONE);
		innerComp.setLocation(new Point(210,10));
		innerComp.setSize(new Point(300,100));
		innerComp.setBackground(display.getSystemColor(SWT.COLOR_RED));
		innerComp.setLayout(new GridLayout(2,false));
		
		Text t = new Text(innerComp,SWT.BORDER);
		t.setLayoutData(new GridData());
		t.setText("Hello");
		
		// innerComp.layout();
		
		shell.open ();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}
}

Composite (comp) doesn't have components assigned and positioning is done absolutely by calling setPosition(), setSize().


The inner Composite positioned absolutely has an layout-manager but the layout manager doesn't work automatically only if one calls layout(). Is the designed behaviour or a bug?

Tom