
package com.deveshcodelab.examples.swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class SWTSnippet09 extends Composite {
public SWTSnippet09(Composite parent) {
super(parent, SWT.NONE);
setLayout(new RowLayout());
int[] comboStyles = { SWT.SIMPLE, SWT.DROP_DOWN, SWT.READ_ONLY };
for (int idxComboStyle = 0; idxComboStyle < comboStyles.length; ++idxComboStyle) {
Combo combo = new Combo(this, comboStyles[idxComboStyle]);
combo.add("RED");
combo.add("GREEN");
combo.add("BLUE");
combo.select(0);
}
}
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout(SWT.HORIZONTAL));
Composite composite= new SWTSnippet09(shell);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}