import org.eclipse.swt.*; import org.eclipse.swt.custom.*; import org.eclipse.swt.widgets.*; /** * @author Thomas Singer */ public class PaintInvisibleTest { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final StackLayout layout = new StackLayout(); shell.setLayout(layout); for (int i = 0; i < 2; i++) { final StyledText styledText = new StyledText(shell, SWT.READ_ONLY | SWT.BORDER); final String text = String.valueOf(i); styledText.setText(text); styledText.addListener(SWT.Paint, event -> System.out.println(text)); if (i == 0) { layout.topControl = styledText; } } shell.setSize(400, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } }