您可以使用Composite#setTabList(Control[])
定义Composite
的选项卡顺序。
这里是将在Button
小号one
和three
之间标签忽略Button
小号two
和four
一个小例子:
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
Composite content = new Composite(shell, SWT.NONE);
content.setLayout(new GridLayout(2, true));
content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final Button one = new Button(content, SWT.PUSH);
one.setText("One");
final Button two = new Button(content, SWT.PUSH);
two.setText("Two");
final Button three = new Button(content, SWT.PUSH);
three.setText("Three");
final Button four = new Button(content, SWT.PUSH);
four.setText("Four");
Control[] controls = new Control[] {one, three};
content.setTabList(controls);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
EDIT:上述代码可以很容易地被转换成适合您的要求。我自己无法测试,因为Composite
s不是专注的,但你应该明白:
mainPane.setTabList(new Control[] {customPanel1, customPanel2, customPanel3 });
customPanel1.setTabList(new Control[] {});
customPanel2.setTabList(new Control[] {});
customPanel3.setTabList(new Control[] {});
来源
2012-10-17 15:34:50
Baz
这种方法的好处是什么?当用户选择下一个“Composite”时,他/她能够做什么而不关注“Widget”? – Baz
@Baz我们将在另一个组件中显示一些数据并接受键盘输入。 – Eugene