Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Setting the size of a composite, then addLayout() ?
Setting the size of a composite, then addLayout() ? [message #460399] Wed, 24 August 2005 15:19 Go to next message
Matt is currently offline MattFriend
Messages: 19
Registered: July 2009
Junior Member
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.
Re: Setting the size of a composite, then addLayout() ? [message #460402 is a reply to message #460399] Wed, 24 August 2005 16:47 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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.
Re: Setting the size of a composite, then addLayout() ? [message #460406 is a reply to message #460402] Wed, 24 August 2005 20:57 Go to previous message
Matt is currently offline MattFriend
Messages: 19
Registered: July 2009
Junior Member
I'm sure I tried that, but I'm unsure..
Though I am setting the layout before I add items to the composite.. I will try it that way tomorrow morning then, & will post results :)

Thanks.
Previous Topic:swt browser on pocket pc
Next Topic:capture the mouse
Goto Forum:
  


Current Time: Fri Apr 26 20:10:19 GMT 2024

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

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

Back to the top