有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为不同的IWizardPages设置不同的窗口标题

我有一个JFace向导,我想为不同的向导页面设置不同的窗口标题。目前,我已经重写了名为setWindowTitle的方法,并且我正在从向导页面调用此方法,但向导页面上没有显示标题

向导上的代码是

@Override
public void setWindowTitle(String newTitle) {
    super.setWindowTitle(newTitle);
}

在JFace向导页面上是

private InstallationWizard iWizard = new InstallationWizard();
        iWizard.setWindowTitle(PropertyClass.getPropertyLabel(Constants.QTL_INSTALLATION_WIZARD_1));

共 (1) 个答案

  1. # 1 楼答案

    在向导中重写getWindowTitle(),如下所示:

    @Override
    public String getWindowTitle() {
        if (getContainer() != null) {
            IWizardPage currentPage = getContainer().getCurrentPage();
    
            if (currentPage == wizardPage1)
                return "title1";
            else if (currentPage == wizardPage2)
                return "title2";
        }
    
        return "otherwise";
    }