gpt4 book ai didi

java - 如何在 Eclipse RCP 3.x 中设置向导窗口的标题?

转载 作者:行者123 更新时间:2023-11-30 08:26:12 25 4
gpt4 key购买 nike

如何在Eclipse RCP 3.x中设置向导窗口的标题?

这段代码

    Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
WizardDialog dialog = new WizardDialog(shell, new ChatNewWizard());
dialog.setTitle("New chat");
dialog.open();

从处理程序中执行,没有任何效果。

这段代码

getShell().setText("New chat");

和这段代码

((WizardDialog)getContainer()).setTitle("New chat");

都从 addPages() 执行也没有效果。

更新

下面的代码

public class RunWizardHandler extends AbstractHandler {

public static class MyWizardPage extends WizardPage {

protected MyWizardPage() {
super("Page Name", "Page Title", null);
setDescription("Page Description");
}

@Override
public void createControl(Composite parent) {

Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());

Label label = new Label(composite, SWT.NONE);
label.setText("Label Text");

setControl(composite);
}

}

public static class MyWizard extends Wizard {

@Override
public void addPages() {
addPage(new MyWizardPage());
}

@Override
public boolean performFinish() {
return false;
}

}

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
WizardDialog dialog = new WizardDialog(shell, new MyWizard());
dialog.open();

return event;
}



}

从简单示例运行,给出以下窗口

enter image description here

即它将“页面标题”放入位置 1,而我想在位置 2 中设置文本。

最佳答案

使用 WizardPage(String pageName, String title, ImageDescriptor titleImage) 构造函数为每个页面指定标题。或者在您想要更改标题时调用 WizardPage.setTitle(xxx)

当前的向导页面标题会覆盖正常的对话框标题(即使未设置)。

更新:对于对话框标题栏中的标题,使用 WizardDialog.setWindowTitle 调用(通常在构造函数中)。

关于java - 如何在 Eclipse RCP 3.x 中设置向导窗口的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21735578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com