|
|
|
Re: freezing swt gui [message #501023 is a reply to message #500866] |
Mon, 30 November 2009 17:16 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
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?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05518 seconds