Non resizable window with JFace
Asked Answered
W

1

2

I how it's possible to setup non resizable window with JFace API. Consider code below that creates application window. I can't find any methods to setup window as not resizable on shell object or application window parent. Is there something I'm missing?

public class Application extends ApplicationWindow
{
    public Application()
    {
        super(null);
    }

    protected Control createContents(Composite parent)
    {
        prepareShell();

        return parent;
    }

    protected void prepareShell() {
        Shell shell = getShell();
        shell.setSize(450, 300);
    }

    public static void main(String[] args)
    {
        Application app = new Application();

        app.setBlockOnOpen(true);
        app.open();

        Display.getCurrent().dispose();
    }
}

Thanks for your help.

Whorehouse answered 4/3, 2011 at 8:47 Comment(0)
J
9

As far as I understand you, you want to set shell style bits prior to the shell creation.

Simply add

@Override
public void create() {
    setShellStyle(SWT.DIALOG_TRIM);
    super.create();
}

to your class, to do so. This omits the SWT.RESIZE style bit, therefore prevents resizing..

Jewess answered 4/3, 2011 at 10:28 Comment(1)
@Jewess Interesting. I tried setShellStyle(SWT.SHELL_TRIM & ~SWT.RESIZE) but it didn't work. Why?Nutrient

© 2022 - 2024 — McMap. All rights reserved.