|
Re: Setting the size of a composite, then addLayout() ? [message #460402 is a reply to message #460399] |
Wed, 24 August 2005 16:47 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Matt,
You need to invoke layout() on the Composite, example snippet is below:
public static void main(String[] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setBounds (10,10,200,200);
final Composite composite = new Composite(shell, SWT.BORDER);
composite.setBounds(10,10,180,150);
Button b1 = new Button(composite, SWT.PUSH);
b1.setText("Push");
b1.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
composite.setLayout(new GridLayout(2, true));
composite.layout(); // <--------
}
});
b1.setBounds(10,20,30,40);
new Button(composite, SWT.PUSH).setBounds(50,60,70,80);
shell.open ();
while (!shell.isDisposed ()){
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
Grant
"Matt" <hibbs40@nildram.co.uk> wrote in message
news:7706706.1124896774870.JavaMail.root@cp1.javalobby.org...
> Ok.. so it seems you can't set the size of a composite within a shell..
then set a layout manager on this composite (to organise widgets within the
composite itself)?
>
> It's giving me a headache..
>
> I don't get why that doesn't work.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03723 seconds