简体   繁体   English

如何将Swing窗口移出屏幕?

[英]How to bring Swing window offscreen?

I work on a Java Swing application that allows displaying frames scattered on multiple screens. 我在Java Swing应用程序上工作,该应用程序允许显示分散在多个屏幕上的帧。

The problem is, when in dual screen, a frame can be saved in secondary monitor 2 but when the application is loaded on only one monitor, the frame is off-screen and hence is not visible. 问题是,在双屏幕中,可以在辅助监视器2中保存一个框架,但是当应用程序仅在一个监视器上加载时,该框架在屏幕外,因此不可见。

Does someone knows a way to identify and recover the frame to the main screen using Java Standard API? 有人知道使用Java Standard API识别帧并将其恢复到主屏幕的方法吗?

I think you could use: 我认为您可以使用:

public abstract GraphicsDevice[] getScreenDevices() throws HeadlessException 

Returns an array containing all the GraphicsDevice objects that represent screen devices 返回一个包含所有表示屏幕设备的GraphicsDevice对象的数组

http://docs.oracle.com/javase/6/docs/api/java/awt/GraphicsEnvironment.html#getScreenDevices() http://docs.oracle.com/javase/6/docs/api/java/awt/GraphicsEnvironment.html#getScreenDevices()

if this method give you list of two or more items then you have multimonitor environment. 如果此方法列出了两个或多个项目,则说明您具有多监视器环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM