Non resizable window with JFace

喜你入骨 提交于 2019-12-22 12:15:38

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/5191515/non-resizable-window-with-jface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!