final Display display = new Display();
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
FormData fd;
shell.setLayout(new FormLayout());
final Composite right = new Composite(shell, SWT.NONE);
right.setLayout(new FormLayout());
final Browser b = new Browser(right, SWT.BORDER);
fd = new FormData();
fd.top = new FormAttachment(0, INDENT);
fd.left = new FormAttachment(0, INDENT);
fd.right = new FormAttachment(100, -INDENT);
fd.bottom = new FormAttachment(100, -INDENT);
b.setLayoutData(fd);
// black so we can see the flicker better
b.setText("<html><body BGCOLOR=black></body></html>");
fd = new FormData();
fd.top = new FormAttachment(0);
fd.left = new FormAttachment(50);
fd.bottom = new FormAttachment(100);
fd.right = new FormAttachment(100);
right.setLayoutData(fd);
shell.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
// code here to resulting in a need to re-layout
right.getParent().layout();
}
});
Listener l = new Listener() {
public void handleEvent(Event event) {
Point size = ((Control) event.widget).getSize();
event.gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
event.gc.fillOval(0, 0, INDENT, INDENT);
event.gc.fillOval(size.x - INDENT, 0, INDENT, INDENT);
event.gc.fillOval(size.x - INDENT, size.y - INDENT, INDENT, INDENT);
event.gc.fillOval(0, size.y - INDENT, INDENT, INDENT);
// mimic other work
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
right.addListener(SWT.Paint, l);
shell.setSize(200, 200);
shell.open();
while (!shell.isDisposed()) {
if (display.readAndDispatch()) {
display.sleep();
}
}