[英]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) 现在我的问题是,我似乎找不到办法将窗口向后推,并迫使其将焦点放到其他窗口,对话框甚至Google Chrome之类的东西放到窗口前面,如果用户在未插入辅助监视器的情况下启动程序,或者如果断开了辅助监视器的连接,则可能会出现问题(在两种情况下,全屏窗口都将出现在主显示器上)
Is there a way to give other windows, JFrames or whatever is needed focus above the Window? 有没有办法给其他窗口,JFrames或窗口上方需要的焦点? 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)? 还是有某种我不知道的侦听器,如果它移到主显示时会允许我处置全屏窗口(我曾尝试在扩展Window的类中实现ComponentListener)?
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. setFillScreen
是一种用于将程序设置为“全屏独占模式”的方法,这意味着您的应用程序对屏幕具有独占控制权,并且不应呈现任何其他程序。
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
在这种情况下,您应该使用Frame#setExtendedState
并将其传递给Frame.MAXIMIZED_BOTH
You may also want to look at setUndecorated
您可能还想看看setUndecorated
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.