Search code examples
javaswtjfaceresizable

Non resizable window with JFace


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.


Solution

  • 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..