import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class CompositePaintListener {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell (display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL);
final Composite composite = new Composite (shell, SWT.BORDER);
composite.setSize (700, 600);
final Color red = display.getSystemColor (SWT.COLOR_RED);
composite.addPaintListener (new PaintListener() {
public void paintControl (PaintEvent e) {
e.gc.setBackground (red);
e.gc.fillOval (5, 5, 690, 590);
}
});
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
|