Java 如何获取向导页面中的所有字段?
我有一个包含许多文本字段的向导页面。现在我想对所有这些字段执行类似的操作,比如setToolTip。所有工具提示都相同。所以我想知道我是否可以得到页面中的所有小部件,然后检查它们是否是文本字段,是否是文本字段集工具提示。这将避免我必须为所有文本字段编写类似的代码行。您可以使用如下内容递归页面中的控件:Java 如何获取向导页面中的所有字段?,java,eclipse,eclipse-plugin,Java,Eclipse,Eclipse Plugin,我有一个包含许多文本字段的向导页面。现在我想对所有这些字段执行类似的操作,比如setToolTip。所有工具提示都相同。所以我想知道我是否可以得到页面中的所有小部件,然后检查它们是否是文本字段,是否是文本字段集工具提示。这将避免我必须为所有文本字段编写类似的代码行。您可以使用如下内容递归页面中的控件: Composite body = (Composite)getControl(); findText(body); ... private void findText(Composite c
Composite body = (Composite)getControl();
findText(body);
...
private void findText(Composite composite)
{
Control [] children = composite.getChildren();
if (children == null || children.length == 0)
return;
for (Control child : children)
{
if (child == null || child.isDisposed())
continue;
if (child instanceof Composite)
findText((Composite)child);
if (child instanceof Text)
{
... handle Text control
}
}
}