Java Tutorial/SWT/TabSequence
Focus Traversal: organize tab sequence in Control.setTabList(Control[] c)
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.rubo;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class FocusTraversal {
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new RowLayout());
Composite composite1 = new Composite(shell, SWT.BORDER);
composite1.setLayout(new RowLayout());
composite1.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
Button button1 = new Button(composite1, SWT.PUSH);
button1.setText("Button1");
Button button3 = new Button(composite1, SWT.PUSH);
button3.setText("Button3");
Button radioButton1 = new Button(composite1, SWT.RADIO);
radioButton1.setText("radio-1");
Button radioButton2 = new Button(composite1, SWT.RADIO);
radioButton2.setText("radio-2");
Composite composite2 = new Composite(shell, SWT.BORDER);
composite2.setLayout(new RowLayout());
composite2.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
Button button2 = new Button(composite2, SWT.PUSH);
button2.setText("Button2");
Combo combo = new Combo(composite2, SWT.DROP_DOWN);
combo.add("combo");
combo.select(0);
composite1.setTabList(new Control[]{button1, button3});
composite2.setTabList(new Control[]{button2, combo});
shell.setTabList(new Control[]{composite2, composite1});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}