Skip to main content



      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 14:59 Go to next message
Eclipse UserFriend
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 15:19 Go to previous messageGo to next message
Eclipse UserFriend
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 15:36 Go to previous messageGo to next message
Eclipse UserFriend
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 13:09 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 08:04:11 EDT 2025

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

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

Back to the top