Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layout problem in 3.1?
Layout problem in 3.1? [message #448999] Mon, 17 January 2005 15:56 Go to next message
Jaap Reitsma is currently offline Jaap ReitsmaFriend
Messages: 69
Registered: July 2009
Member
Hi all,

I wondered if somebody noticed the following behaviour: The program below
first sets the size of the shell, then adds a GridLayout and a number of
children. The behaviour is that only the sheel is drawn.

However, when moving the shell.setSize after the addition of the children,
everything seems Ok!

This seems a bit odd to me. Is there an explanation? I am using eclipse
3.1M4. In Eclipse 3.0.1 it works fine though. This is a very silly problem.

public class DemoFullTimelineControl {
public static void main(String args[]) {
try {
Display display = Display.getDefault();
Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setText("SWT Application");
shell.setSize(410, 503); // Children are not drawn!

final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
shell.setLayout(gridLayout);

final Label label = new Label(shell, SWT.NONE);
label.setText("label");

final Scale scale = new Scale(shell, SWT.NONE);
// shell.setSize(410, 503); // Only now the children are drawn too

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
}

}


Kind regards,

Jaap
Re: Layout problem in 3.1? [message #449004 is a reply to message #448999] Mon, 17 January 2005 16:52 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
A layout is applied either after a resize event or after calling
Composite.layout(boolean).

You have two options in the example below, either call shell.setSize(410,
503) after configuring the layout (e.g. just before shell.open()) OR call
shell.layout(false) after configuring the layout (e.g. just before
shell.open()) .

In eclipse 3.0.1, shell.open() gave a free resize event on some platforms
(Windows). In eclipse 3.1 we have made the resize behaviour consistent
across all platforms. Therefore, in 3.1 you will only get a resize event on
shell.open() if you have never set the size or bounds of the shell.

"Jaap Reitsma" <Jaap.Reitsma@telin.nl> wrote in message
news:csgn86$pbq$1@www.eclipse.org...
> Hi all,
>
> I wondered if somebody noticed the following behaviour: The program below
> first sets the size of the shell, then adds a GridLayout and a number of
> children. The behaviour is that only the sheel is drawn.
>
> However, when moving the shell.setSize after the addition of the children,
> everything seems Ok!
>
> This seems a bit odd to me. Is there an explanation? I am using eclipse
> 3.1M4. In Eclipse 3.0.1 it works fine though. This is a very silly
> problem.
>
> public class DemoFullTimelineControl {
> public static void main(String args[]) {
> try {
> Display display = Display.getDefault();
> Shell shell = new Shell(display, SWT.SHELL_TRIM);
> shell.setText("SWT Application");
> shell.setSize(410, 503); // Children are not drawn!
>
> final GridLayout gridLayout = new GridLayout();
> gridLayout.numColumns = 2;
> shell.setLayout(gridLayout);
>
> final Label label = new Label(shell, SWT.NONE);
> label.setText("label");
>
> final Scale scale = new Scale(shell, SWT.NONE);
> // shell.setSize(410, 503); // Only now the children are drawn too
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> }
>
>
> Kind regards,
>
> Jaap
>
>
>
Previous Topic:[GC] Capture offscreen image
Next Topic:When to use multi-UI threading ?
Goto Forum:
  


Current Time: Sat Apr 27 05:07:23 GMT 2024

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

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

Back to the top