|
|
Re: Layout in Group not working properly [message #445353 is a reply to message #445352] |
Wed, 03 November 2004 20:36 |
Luc Rochefort 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 |
Steve Northover 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();
>
> }
> }
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03088 seconds