ImLearning
ImLearning

Reputation: 200

Disable the window resize on JFace WizardPage

I want to disable the button maximize/minimize, below I post image to explain

enter image description here

this is my code :

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;
}
}

I tried to get the Composite's Shell like this "container.getShell();" but I don't understand How I can set these parameters "SWT.SHELL_TRIM | SWT.TOOL"! Thanks

Upvotes: 0

Views: 2447

Answers (4)

anonymous
anonymous

Reputation: 21

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

} public class DisableMax extends WizardDialog {

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

Upvotes: 1

Ravi
Ravi

Reputation: 553

Is it a File -> New wizard or a custom wizard that is programatically launched. If it is custom, you would have to create WizardDialog and then pass Wizard instance to it. When creating WizardDialog, you would also create Shell, for which you can send the argument without SWT.RESIZE. For File -> New, since the dialog is not created by you, I dont think you can control resize option there. The resize can only be passed in the constructor of Shell.

Upvotes: 1

Aslam
Aslam

Reputation: 126

In case of dialogs, I have observed that I need to explicitly specify that I need min, max buttons at upper-right corner. For that I need to call the below method in a constructor:

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

Since Wizard is also a dialog, I can call the above method to reset the shellStyle not to include max, min, and other buttons (see above code). The wizard by default might be adding these buttons. But I think you can override this by recalling at the end of wizard creation. Hope this helps.

Upvotes: 1

E-Riz
E-Riz

Reputation: 33034

Controlling the Window/Shell is not the responsibility of a WizardPage, it can not do that. It's the responsibility of the WizardDialog or the code that creates it. In fact, there is no guarantee that a Wizard and its WizardPages will even be contained in a WizardDialog; anything can implement the IWizardContainer interface to present wizards in a different way.

Upvotes: 2

Related Questions