justingiffard
justingiffard

Reputation: 53

How to listen for a change in java.awt.Window screen? Is there a way to give focus to other windows/programs whilst using setFullScreenWindow()?

I have a full screen Window made like this

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
if (gs.length >= 1)
    gs[1].setFullScreenWindow(frame);
else 
    gs[0].setFullScreenWindow(frame);

This puts the frame on the second monitor unless there is no second monitor in which case it puts the Window on the primary monitor

Now my problem is that I can't seem to find a way to push the window to the back and force it to loose focus to that other windows, dialogs and even things such as Google Chrome go in front of the window -- which could be a problem if the user starts the program without a secondary monitor plugged in or if the secondary monitor gets unplugged (in both cases the fullscreen Window ends up on the primary display)

Is there a way to give other windows, JFrames or whatever is needed focus above the Window? Or is there some sort of Listener that I don't know about that will allow me to dispose of the fullscreen window in the event that it gets moved to the primary display (I have tried implementing ComponentListener in the class that extends Window)?

Upvotes: 0

Views: 531

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347194

setFillScreen is a method used to set your program in "full screen exclusive mode", meaning, your application has exclusive control over the screen, and no other program's should be rendered.

Do you actually just want to maximise the window instead? In which case you should be using Frame#setExtendedState and passing it Frame.MAXIMIZED_BOTH

You may also want to look at setUndecorated

Upvotes: 1

Related Questions