[英]how to clear the fields in a jface Wizard on pressing the back button
I have created a JFace wizard PCWizard
extending Wizard
and have four pages PCPageOne
, PCPageTwo
, PCPageThree
and PCPageFour
extending WizardPage
. 我创建了一个JFace向导
PCWizard
扩展Wizard
并有四页PCPageOne
, PCPageTwo
, PCPageThree
和PCPageFour
扩展WizardPage
。
I have also captured the data collected in another class, if u want me to override the WizardDialog
class and do the action how do I do it . 我还捕获了在另一个类中收集的数据,如果你想让我覆盖
WizardDialog
类并执行操作我该怎么做。 I'm new to java and SWT a more elaborate explanation would be fine.Thanx in advance 我是java和SWT的新手,更精细的解释会很好。提前做好准备
To disable the back button do the following in the last page: 要禁用后退按钮,请在最后一页中执行以下操作:
@Override
public IWizardPage getPreviousPage() {
// prevent going back
return null;
}
Also clearing the input in pages might be done in a IPageChangedListener
: 清除页面中的输入也可以在
IPageChangedListener
完成:
WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
dialog.addPageChangedListener(new IPageChangedListener() {
public void pageChanged(PageChangedEvent event) {
// this is just a suggestion..
IClearablePage page = (IClearablePage)event.getSelectedPage();
page.clear();
}
});
Where IClearablePage
is your own interface with a clear()
, and all your pages implement IClearablePage
. 其中
IClearablePage
是您自己的带有clear()
的接口,并且您的所有页面都实现了IClearablePage
。
EDIT: override setVisible
as greg stated in his answer is probably more convenient. 编辑:覆盖
setVisible
因为greg在他的回答中说明可能更方便。
Override the WizardPage
setVisible
method to clear fields when the page becomes active: 当页面变为活动状态时,覆盖
WizardPage
setVisible
方法以清除字段:
@Override
public void setVisible(final boolean visible)
{
super.setVisible(visible);
if (visible) {
// TODO clear your fields
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.