在JFace WizardPage上禁用窗口大小调整

时间:2012-05-15 12:35:26

标签: eclipse eclipse-plugin swt jface

我想禁用按钮最大化/最小化,下面我发布图片来解释

enter image description here

这是我的代码:

public class ProjectWizardPageOne extends WizardPage {

private String platform;

public ProjectWizardPageOne(String title) {
    super(title);
    this.setTitle(title);
    this.setMessage("Configure Project Name and Location");
}

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent,SWT.NONE);
    setPageComplete(false);
    setControl(container);

    Canvas leftPanel = new Canvas(container, SWT.NONE);
    leftPanel.setBackgroundImage(new Image(leftPanel.getDisplay(), this
            .getClass().getClassLoader()
            .getResourceAsStream("/icons/mypicture.png")));
    leftPanel.setBounds(0, 0, 183, 282);

    Composite rightContainer = new Composite(container, SWT.NONE);
    rightContainer.setBackground(new Color(null, 255, 255, 255));
    rightContainer.setBounds(181, 0, 399, 282);
}

public String getPlatform() {
    return platform;
}

public void setPlatform(String platform) {
    this.platform = platform;
}
}

我试图像这样的“container.getShell();”获得Composite的Shell。 但我不明白如何设置这些参数“SWT.SHELL_TRIM | SWT.TOOL”! 感谢

4 个答案:

答案 0 :(得分:2)

控制Window / Shell不是WizardPage的责任,它不能做到这一点。它是WizardDialog或创建它的代码的责任。事实上,无法保证Wizard及其WizardPage甚至可以包含在WizardDialog中;任何事都可以实现IWizardContainer接口以不同的方式呈现向导。

答案 1 :(得分:1)

如果是对话框,我发现我需要明确指出我需要在右上角的最小,最大按钮。为此,我需要在构造函数中调用以下方法:

setShellStyle(getShellStyle() | SWT.MAX | SWT.MIN | SWT.RESIZE);

由于Wizard也是一个对话框,我可以调用上面的方法来重置shellStyle,不包括max,min和其他按钮(参见上面的代码)。默认情况下,向导可能是添加这些按钮。但我认为您可以通过在向导创建结束时重新调用来覆盖它。希望这会有所帮助。

答案 2 :(得分:1)

是文件 - >以编程方式启动的新向导或自定义向导。如果是自定义的,则必须创建WizardDialog,然后将Wizard实例传递给它。创建WizardDialog时,您还可以创建Shell,您可以在不使用SWT.RESIZE的情况下发送参数。对于文件 - >新的,因为对话框不是由你创建的,我不认为你可以在那里控制调整大小选项。 resize只能在Shell的构造函数中传递。

答案 3 :(得分:1)

public class InstallerWizard extends Wizard{
...
main()
{
WizardDialog dialog = new DisableMax(shell, new InstallerWizard());
dialog.open();
}

}     public class DisableMax扩展了WizardDialog {

    public DisableMax(Shell parentShell, IWizard newWizard) {
        super(parentShell, newWizard);
        setShellStyle(SWT.CLOSE | SWT.MIN | SWT.RESIZE | getDefaultOrientation());
    }
}
相关问题