import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class SwtTest {
static public void main(String args[]) {
Display display = new Display();
final Shell shell = new Shell(display);
Canvas canvas = new Canvas(shell, SWT.NONE);
canvas.setSize(400, 300);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
Rectangle clientArea = shell.getClientArea();
e.gc.drawLine(0, 0, clientArea.width, clientArea.height);
e.gc.drawLine(clientArea.width, 0, 0, clientArea.height);
}
});
shell.setText("SwtTest");
shell.pack();
shell.open();
while ( ! shell.isDisposed()) {
if ( ! display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}