如果您在其他几个页面上
- 彼此完全不同
- 取决于上一页中的先前选择
然后,您可以动态添加下一页(也如此处所述)
但是,如果只有下一页包含动态内容,则应该可以在方法中创建该内容
onEnterPage()
public void createControl(Composite parent){ // // create the composite to hold the widgets // this.composite = new Composite(parent, SWT.NONE); // // create the desired layout for this wizard page // GridLayout layout = new GridLayout(); layout.numColumns = 4; this.composite.setLayout(layout); // set the composite as the control for this page setControl(this.composite);}void onEnterPage(){ final MacroModel model = ((MacroWizard) getWizard()).model; String selectedKey = model.selectedKey; String[] attrs = (String[]) model.macroMap.get(selectedKey); for (int i = 0; i < attrs.length; i++) { String attr = attrs[i]; Label label = new Label(this.composite, SWT.NONE); label.setText(attr + ":"); new Text(this.composite, SWT.NONE); } pack();}如日食专栏文章“
创建JFace向导”所示:
我们可以通过覆盖任何向导页面的getNextPage方法来更改向导页面的顺序。在离开页面之前,我们将用户选择的值保存在模型中。在我们的示例中,根据旅行的选择,用户接下来将看到带航班的页面或乘车旅行的页面。
public IWizardPage getNextPage(){ saveDataToModel(); if (planeButton.getSelection()) { PlanePage page = ((HolidayWizard)getWizard()).planePage; page.onEnterPage(); return page; } // Returns the next page depending on the selected button if (carButton.getSelection()) { return ((HolidayWizard)getWizard()).carPage; } return null;}我们
定义了一种方法来对此进行初始化PlanePage
,onEnterPage()
并在移至时调用此方法PlanePage
,即在getNextPage()
第一页的方法中。



