关于java tab键顺序的问题

来源:百度知道 编辑:UC知道 时间:2024/05/12 01:24:28
本人在界面中设置了很多的控件,想控制tab的顺序。
我使用composite.setTabList(new Control[]{text_name, combo_sex, text_country});语句进行设置。
其中,text_name, combo_sex, text_country为composite中的部件。但是每次运行到此处抛出异常。

ava.lang.IllegalArgumentException: Argument not valid
at org.eclipse.swt.SWT.error(SWT.java:3761)
at org.eclipse.swt.SWT.error(SWT.java:3695)
at org.eclipse.swt.SWT.error(SWT.java:3666)
at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
at org.eclipse.swt.widgets.Composite.setTabList(Composite.java:999)
at com.hcls.ui.view.dialog.CustomerEditorDialog.createDialogArea(CustomerEditorDialog.java:290)
at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java:760)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
at org.eclipse.jface.window.Window.open(Window.java:790)
at com.hcls.ui.action.CustomerActionGroup$AddPoteCustomerAction.run(CustomerActionGro

我觉得不应该用 Composite.setTabList(...),因为Composite只是个接口,这个接口里面不包括setTabList()方法. 所以你应该用一个包含setTabList()方法的Composite类的子类。我在百度上查看一下 setTabList(),发现别人都是用Shell,这是个eclipse的第三方包.

Some thing like this:

import org.eclipse.swt.widgets.Shell;
Shell shell;
shell.setTabList(new Control[] { httpText, combo, viewBtn, resetBtn,
exitBtn, saveBtn });

(new Control[]{text_name, combo_sex, text_country})
new构造要有括号结束吧,如果你弄不明白可以先新建个Control,然后把这些一个一个赋值进去

没有弄过Java桌面系统