Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layout in Group not working properly
Layout in Group not working properly [message #445351] Wed, 03 November 2004 19:59 Go to next message
Luc Rochefort is currently offline Luc RochefortFriend
Messages: 8
Registered: July 2009
Junior Member
Hi!

I can't seem to make layouts work in groups. Maybe I do something wrong.

Check this out:

public class Layouttest {

public static void main(String[] args) {
Display d = new Display();
Shell s = new Shell(d);
Group g = new Group(s, SWT.BORDER);
g.setBounds(s.getClientArea());
g.setLayout(new FillLayout(SWT.VERTICAL));
Button b1 = new Button(g.getShell(), SWT.PUSH);
Button b2 = new Button(g.getShell(), SWT.PUSH);
Button b3 = new Button(g, SWT.PUSH);
s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch()) {
d.sleep();
}
}
d.dispose();
}
}
Re: Layout in Group not working properly [message #445352 is a reply to message #445351] Wed, 03 November 2004 20:19 Go to previous messageGo to next message
Luc Rochefort is currently offline Luc RochefortFriend
Messages: 8
Registered: July 2009
Junior Member
Rushman wrote:

> Hi!

> I can't seem to make layouts work in groups. Maybe I do something wrong.

> Check this out:

> public class Layouttest {

> public static void main(String[] args) {
> Display d = new Display();
> Shell s = new Shell(d);
> Group g = new Group(s, SWT.BORDER);
> g.setBounds(s.getClientArea());
> g.setLayout(new FillLayout(SWT.VERTICAL));
> Button b1 = new Button(g.getShell(), SWT.PUSH);
> Button b2 = new Button(g.getShell(), SWT.PUSH);
> Button b3 = new Button(g, SWT.PUSH);
> s.open();
> while (!s.isDisposed()) {
> if (!d.readAndDispatch()) {
> d.sleep();
> }
> }
> d.dispose();
> }
> }

Hi, Rushman again...

I meant to write

Button b1 = new Button(g, SWT.PUSH);
Button b2 = new Button(g, SWT.PUSH);

Still doesn't work...
Re: Layout in Group not working properly [message #445353 is a reply to message #445352] Wed, 03 November 2004 20:36 Go to previous messageGo to next message
Luc Rochefort is currently offline Luc RochefortFriend
Messages: 8
Registered: July 2009
Junior Member
Rushman wrote:

> Rushman wrote:

>> Hi!

>> I can't seem to make layouts work in groups. Maybe I do something wrong.

>> Check this out:

>> public class Layouttest {

>> public static void main(String[] args) {
>> Display d = new Display();
>> Shell s = new Shell(d);
>> Group g = new Group(s, SWT.BORDER);
>> g.setBounds(s.getClientArea());
>> g.setLayout(new FillLayout(SWT.VERTICAL));
>> Button b1 = new Button(g.getShell(), SWT.PUSH);
>> Button b2 = new Button(g.getShell(), SWT.PUSH);
>> Button b3 = new Button(g, SWT.PUSH);
>> s.open();
>> while (!s.isDisposed()) {
>> if (!d.readAndDispatch()) {
>> d.sleep();
>> }
>> }
>> d.dispose();
>> }
>> }

> Hi, Rushman again...

> I meant to write

> Button b1 = new Button(g, SWT.PUSH);
> Button b2 = new Button(g, SWT.PUSH);

> Still doesn't work...


Guess who's back... back again...

I finally got it. In my example, one line was missing.

public class Layouttest {

public static void main(String[] args) {
Display d = new Display();
Shell s = new Shell(d);
Group g = new Group(s, SWT.BORDER);
g.setBounds(s.getClientArea());
g.setLayout(new FillLayout(SWT.VERTICAL));
Button b1 = new Button(g, SWT.PUSH);
Button b2 = new Button(g, SWT.PUSH);
Button b3 = new Button(g, SWT.PUSH);
/* here */ g.layout();

s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch()) {
d.sleep();
}
}
d.dispose();

}
}
Re: Layout in Group not working properly [message #445385 is a reply to message #445353] Thu, 04 November 2004 18:09 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Layout happes when you call layout() or when the size of a control has
changed. If you moved the line "g.setBounds(..." to be after you have
configured the layout and create the buttons, then when the size was
changed, the layout would be in place and layout would happen. The upshot
of this is you could remove the explicit call to layout().

"Rushman" <rochefort@irosoft.com> wrote in message
news:cmbfg2$mcl$1@eclipse.org...
> Rushman wrote:
>
> > Rushman wrote:
>
> >> Hi!
>
> >> I can't seem to make layouts work in groups. Maybe I do something
wrong.
>
> >> Check this out:
>
> >> public class Layouttest {
>
> >> public static void main(String[] args) {
> >> Display d = new Display();
> >> Shell s = new Shell(d);
> >> Group g = new Group(s, SWT.BORDER);
> >> g.setBounds(s.getClientArea());
> >> g.setLayout(new FillLayout(SWT.VERTICAL));
> >> Button b1 = new Button(g.getShell(), SWT.PUSH);
> >> Button b2 = new Button(g.getShell(), SWT.PUSH);
> >> Button b3 = new Button(g, SWT.PUSH);
> >> s.open();
> >> while (!s.isDisposed()) {
> >> if (!d.readAndDispatch()) {
> >> d.sleep();
> >> }
> >> }
> >> d.dispose();
> >> }
> >> }
>
> > Hi, Rushman again...
>
> > I meant to write
>
> > Button b1 = new Button(g, SWT.PUSH);
> > Button b2 = new Button(g, SWT.PUSH);
>
> > Still doesn't work...
>
>
> Guess who's back... back again...
>
> I finally got it. In my example, one line was missing.
>
> public class Layouttest {
>
> public static void main(String[] args) {
> Display d = new Display();
> Shell s = new Shell(d);
> Group g = new Group(s, SWT.BORDER);
> g.setBounds(s.getClientArea());
> g.setLayout(new FillLayout(SWT.VERTICAL));
> Button b1 = new Button(g, SWT.PUSH);
> Button b2 = new Button(g, SWT.PUSH);
> Button b3 = new Button(g, SWT.PUSH);
> /* here */ g.layout();
>
> s.open();
> while (!s.isDisposed()) {
> if (!d.readAndDispatch()) {
> d.sleep();
> }
> }
> d.dispose();
>
> }
> }
>
>
Previous Topic:help : how get cursor beyound the end of line in editor?
Next Topic:SWT_AWT Bridge for Applet?
Goto Forum:
  


Current Time: Tue Oct 27 07:26:55 GMT 2020

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

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

Back to the top