1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
final Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData());
Button button = new Button(shell, SWT.PUSH);
button.setText("Push");
button.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
Label label = new Label(composite, SWT.NONE);
label.setLayoutData(new GridData());
label.setText("Label");
composite.layout(true);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose(); |
Partager