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 33
|
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(200, 200);
shell.setText("Layout Example");
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns =1;
shell.setLayout(gridLayout);
Button button = new Button(shell, SWT.PUSH);
button.setText("add");
final ListViewer viewer = new ListViewer(shell);
GridData data = new GridData();
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = SWT.FILL;
viewer.getControl().setLayoutData(data);
button.addMouseListener(new MouseAdapter() {
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
viewer.getList().add("UNE LIGNE");
};
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
} |
Partager