freezing swt gui [message #499731] |
Mon, 23 November 2009 16:21  |
Eclipse User |
|
|
|
Is there a way to "freeze" the update of the gui while I am making some changes and then after a while make the gui to update again? Is there maybe a way so I can make the program so I have to update the gui manually by running some function?
I hope that someone understands what I want to do.
|
|
|
|
|
Re: freezing swt gui [message #501023 is a reply to message #500866] |
Mon, 30 November 2009 12:16   |
Eclipse User |
|
|
|
I've looked into this a bit closer, and it appears that this case is not
currently working on Cocoa (it does work for me on win32 and gtk). I assume
you're using Cocoa? If so then this may not be supportable there (see the
"Note...hint" comment in setRedraw()'s javadoc). However it would not hurt
to log a report for this with swt to be investigated (
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT ).
However if you're not on Cocoa then this should work. Does the snippet
below work for you? And if so, can you modify it to more closely resemble
your case and show the problem?
public static void main (String [] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
shell.setLayout(new GridLayout());
Composite composite = new Composite(shell, SWT.BORDER);
composite.setLayout(new FillLayout());
final Composite topComposite = composite;
composite = new Composite(composite, SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite, SWT.BORDER);
composite.setLayout(new GridLayout());
Button button1 = new Button(composite, SWT.PUSH);
button1.setText("Button 1");
Label label1 = new Label(composite, SWT.NONE);
label1.setText("Label 1");
shell.open();
display.timerExec(2000, new Runnable() {
public void run() {
System.out.println("shell.setRedraw(false);");
shell.setRedraw(false);
display.timerExec(2000, new Runnable() {
public void run() {
System.out.println("dispose the top Composite");
topComposite.dispose();
display.timerExec(2000, new Runnable() {
public void run() {
System.out.println("create some composites and
label2 and button2");
Composite composite = new Composite(shell,
SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite,
SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite,
SWT.BORDER);
composite.setLayout(new GridLayout());
new Label(composite, SWT.NONE).setText("Label
2");
composite = new Composite(shell, SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite,
SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite,
SWT.BORDER);
composite.setLayout(new GridLayout());
new Button(composite, SWT.PUSH).setText("Button
2");
shell.layout();
display.timerExec(2000, new Runnable() {
public void run() {
System.out.println("shell.setRedraw(true);");
shell.setRedraw(true);
}
});
}
});
}
});
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
"larsk" <larsk7@gmail.com> wrote in message
news:heuplr$mu2$1@build.eclipse.org...
> Grant Gayed wrote on Tue, 24 November 2009 15:48
> > I think Control.setRedraw() is what you want here. If not then please
> > follow up.
> >
> > Grant
>
>
> Thanks for your reply!
> I tested .setRedraw() but my gui is still changing when setRedraw is set
to false.
> In my application I set the setRedraw on a shell to false and then I
dispose all the composites and labels on the shell. Then the app waits for
some seconds and then I put some new composites and labels on the shell. But
I don't want the gui to redraw/update/change until all the new composites
and labels is put on the shell.
> Is this the right way to go? Is it going to work with setRedraw when i
dispose the composites and labels?
|
|
|
|
|
Re: freezing swt gui [message #501574 is a reply to message #501260] |
Wed, 02 December 2009 15:34  |
Eclipse User |
|
|
|
Thanks for all help!
I have written a bug report to eclipse.
But I will also test your suggestion to create a new composite and then dispose the old one.
Grant Gayed wrote on Tue, 01 December 2009 17:53 | Perhaps you could use a StackLayout to first lay out your new set of
controls on a Composite that's not the top control (therefore not visible),
and then set this Composite to be the top control once all of its children
are there and ready to be shown? (then dispose() the no-longer-on-top
Composite with the old set of Controls now that it's no longer visible).
Grant
|
|
|
|
Powered by
FUDForum. Page generated in 0.04440 seconds