开发者

java: any way to detect changes in display configuration?

开发者 https://www.devze.com 2023-02-17 05:48 出处:网络
One of my coworkers would like my Swing app to adapt correctly to the removal of a 2nd display monitor.

One of my coworkers would like my Swing app to adapt correctly to the removal of a 2nd display monitor.

Is there any way to get noti开发者_如何学Pythonfication of this, other than polling to repeatedly compute virtual bounds? (per the code sample in http://download.oracle.com/javase/6/docs/api/java/awt/GraphicsConfiguration.html)


Hum, tricky one. Because GraphicsConfiguration class won't give us any listeners, I'll have only a couple of alternatives:

  1. (If Windows) Use a JNI interface to Windows to detect display settings change and forward them to Java. This would be the SystemEvents::DisplaySettingsChanged Event.

  2. Create a simple polling Thread - timer that retrieves the result of Toolkit.getDefaultToolkit().getScreenSize() as you've already stated before.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号