简体   繁体   English

如何在java.awt.Window屏幕上侦听变化? 使用setFullScreenWindow()时是否有办法将焦点放在其他Windows /程序上?

[英]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.

相关问题 java.awt.Window的全屏问题 - Full screen issue with java.awt.Window 如何重绘java.awt.Window? - How to repaint a java.awt.Window? 在Ubuntu上将全屏设置为java.awt.Window - Setting the full screen to a java.awt.Window on Ubuntu Java“ java.awt.Window”数组在位置0添加项目 - Java “java.awt.Window” Array add Item at position 0 在Swing应用程序启动期间,首次调用JFrame构造函数需要很长时间(因为java.awt.Window()) - First call to JFrame constructor takes a long time during Swing application startup (because of java.awt.Window()) 你为什么要处理一个超出范围的java.awt.Window? - Why should you have to dispose() a java.awt.Window that goes out of scope? 使用Java获取其他程序的活动窗口 - get active window of other programs using java 如何在java.awt.Robot中将焦点设置为窗口 - How to set focus to a window in java.awt.Robot 除了使用 java.awt 机器人 class 之外,如何在 Selenium/Java 中退出全屏(Chrome)? - How to exit full screen (Chrome) in Selenium/Java other than using java.awt Robot class? 如何在Swing / AWT中侦听Window的“ visible”属性? - How to listen for “visible” property of Window in Swing/AWT?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM