如果您是其他几个页面,则该方法是正确的
- 完全不同的一个与另一个
- 取决于在上一页中所做的先前选择
然后您可以动态添加下一页(也如此处所述)
但是,如果您只有一个包含动态内容的下一页,您应该能够在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();
}
如 eclipse 角文章Creating JFace Wizards所示:
我们可以通过覆盖任何向导页面的 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()
第一页的方法中。