如何在多监视器配置中部署 JFrame
我想构建一个有 2 个窗口的应用程序。 第一个应该始终位于第一个监视器中,并且不能最大化。 第二个应该在第二个显示器中启动(一个完美的例子就像 PowerPoint 的演示模式),在任何其他应用程序窗口的“顶部”运行,并且始终最大化。该窗口是使用第一个窗口的侦听器启动的。 请注意,这些“显示器”可能是演示中使用的 LCD 投影仪,也可能是真正的台式计算机显示器。
我知道存在 GraphicsEnvironment API,我们可以知道我们的显示器配置是被视为单个显示器,还是单独处理。但是,我不知道如何实施。我的意思是,由于屏幕配置可以根据显卡的不同进行不同的处理,我们如何验证它们?
例如,如果有 3 个显示器被视为具有高分辨率的单个显示器,那么也许我们可以将第二个窗口的坐标 x0 设置为:total_width * 2 / 3。 但是,如果将其视为单独的监视器怎么办?
谢谢。
I'd like to build an app that has 2 windows.
The first one should always be in the first monitor, and can't be maximized.
The second one should be launched in second monitor (a perfect example is like PowerPoint's presentation mode), is running "on top" of any other applications' window, and always maximized. This window is launched using a listener given to the first window.
Note that these "monitors" may be LCD projectors used in presentations, or real desktop computer monitors.
I know that there exists GraphicsEnvironment API, and we can know whether our monitor configuration is treated as a single monitor, or treated separately. But, I don't know how to implement it. I mean, since screen configurations can be treated differently depending on their graphic cards, how do we validate them?
For example, if there are 3 monitors treated as a single monitor with large resolution, then perhaps we can set a coordinate x0 for second window as : total_width * 2 / 3.
But, what if it is treated as seperate monitors..?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@Zecas:是的,效果很好。很抱歉没有在这里发布答案。我完全忘记了。
所以,解决方案正如ShivanDragon所说的那样,我们可以通过首先获取我们的GraphicsEnvironment来单独获取每个显示器,然后从Environment中获取我们的屏幕设备:
之后,只需使用:
@Zecas : Yes, it worked out well. Sorry for not posting the answer here. I totally forgot.
So, the solution is exactly as what ShivanDragon has stated, we can get each monitor individually by obtaining our GraphicsEnvironment first, and then get our screen devices from the Environment:
After that, just use: