import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class ComboSelectedIndex {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Show Message Box");
shell.setLayout(new GridLayout(2, false));
new Label(shell, SWT.NONE).setText("Icon:");
final Combo icons = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
icons.add("A");
icons.add("B");
icons.add("C");
icons.select(0);
new Label(shell, SWT.NONE).setText("Buttons:");
final Combo buttons = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
buttons.add("1");
buttons.add("2");
buttons.select(0);
new Label(shell, SWT.NONE).setText("Return:");
final Label returnVal = new Label(shell, SWT.NONE);
returnVal.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Button button = new Button(shell, SWT.PUSH);
button.setText("Show Message");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
returnVal.setText("");
returnVal.setText(icons.getSelectionIndex() + " " + buttons.getSelectionIndex());
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}