[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-swt-dev] Display.asyncExec premepts pending events
|
Randy, the following code works in the latest SWT, but fails in 2.0.
public static void main(String[] args) {
final Display display = new Display ();
final Color gray = display.getSystemColor (SWT.COLOR_GRAY);
final Color darkGray = display.getSystemColor (SWT.COLOR_DARK_GRAY);
Shell shell = new Shell (display);
shell.setLayout (new RowLayout ());
Button button1 = new Button (shell, SWT.NONE);
button1.setText ("foo");
Button button2 = new Button (shell, SWT.NONE);
button2.setText ("foo");
final Composite composite = new Composite (shell, SWT.NULL);
composite.setLayoutData (new RowData (30, 30));
display.asyncExec (new Runnable () {
public void run () {
if (composite.isDisposed ()) return;
if (composite.getBackground ().equals (gray)) {
composite.setBackground (darkGray);
} else {
composite.setBackground (gray);
}
display.asyncExec (this);
}
});
shell.setSize (300, 300);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}