import org.eclipse.swt.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; /** * @author Thomas Singer */ public class SkinEventSentInWrongOrder { public static void main(String[] args) { final Display display = new Display(); display.addListener(SWT.Skin, event -> { System.out.println(event.widget.getClass()); if (event.widget instanceof Shell) { final Shell shell = (Shell)event.widget; shell.setForeground(display.getSystemColor(SWT.COLOR_YELLOW)); shell.setBackground(display.getSystemColor(SWT.COLOR_GRAY)); } else if (event.widget instanceof Control) { final Control control = (Control)event.widget; final Composite parent = control.getParent(); control.setForeground(parent.getForeground()); control.setBackground(parent.getBackground()); } }); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Composite initialParent = new Composite(shell, 0); final Label label = new Label(initialParent, 0); label.setText("hello world"); final Composite newParent = new Composite(shell, 0); newParent.setLayout(new GridLayout()); label.setParent(newParent); shell.setSize(400, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } }