Ich versuche zwei Button mit FillLayout in einem Composite anzeigen zu lassen. Leider werden sie nicht angezeigt. Was mache ich falsch?
Code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* @author Timmi
*
* created first in project layouts
*/
public class FillLayoutTest2
{
public static Display myDisplay;
private void fillLayoutDemo2(Display display)
{
myDisplay = display;
final Shell myShell = new Shell(myDisplay);
myShell.setText("FillLayout Shell");
Composite myComposite = new Composite(myShell, SWT.BORDER);
FillLayout fillLayout = new FillLayout();
fillLayout.type = SWT.VERTICAL;
myComposite.setLayout(fillLayout);
myComposite.setSize(300, 200);
Button but1 = new Button(myComposite,SWT.PUSH);
but1.setText("Eins");
Button but2 = new Button(myComposite,SWT.PUSH);
but2.setText("Zwei");
myShell.pack();
myShell.open();
while (!myShell.isDisposed())
{
if (!myDisplay.readAndDispatch())
myDisplay.sleep();
}
}
/**
* Method main
* @param args
*/
public static void main(String[] args)
{
myDisplay = new Display();
FillLayoutTest2 flt = new FillLayoutTest2();
flt.fillLayoutDemo2(myDisplay);
}
}