navy1978
navy1978

Reputation: 1439

SWT: Change style of a Shell at runtime

Is there a way to change the style of a Shell at runtime?

I would like to have a shell not resizable but capable to fill, with its content, the whole screen, when it's in fullscreen. Is there a way to accomplish that?

In other words, when a Shell is not resizable and it has for example a Background Image I get this in full screen : enter image description here

On the other hand when the Shell is resizable and I go in full screen I get this: enter image description here

So would like to obtain the second effect but with a not resizable Shell.

Any help would be appreciated.

Upvotes: 2

Views: 650

Answers (1)

navy1978
navy1978

Reputation: 1439

Following Stefan's comment, I was able to do it listening to the resize event and checking the fullscreen flag, resizing appropriately the shell's size to the monitor size when it's in full screen and to normal size when is not. Here the code that does the trick:

shell.addListener(SWT.Resize, new Listener() {
            @Override
            public void handleEvent(Event arg0) {
                if (shell.getFullScreen()) {
                    Rectangle r = getMonitorSize(shell);
                    shell.setSize(r.width, r.height);
                    shell.redraw();
                } else {
                    shell.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
                    shell.redraw();
                }
            }
        });

Upvotes: 1

Related Questions