开发者

java: any way to detect changes in display configuration?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜