1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Composite composite = new Composite(shell, SWT.BORDER);
composite.setBackground(new Color(display, 255, 0, 0));
GridLayout layout = new GridLayout(2, false);
composite.setLayout(layout);
final Canvas canvas = new Canvas(composite, SWT.BORDER);
canvas.setSize(32,32);
final Image image = new Image(display, new ImageData("icons/ok.png"));
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
System.out.println(canvas.getClientArea());
e.gc.drawImage(image, 0, 0);
}
});
Label userIdLabel = new Label(composite, SWT.BORDER);
userIdLabel.setText("&User id:");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
} |