本文介绍了如何在多监视器配置中部署JFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个具有2个窗口的应用程序.第一个应该始终在第一个监视器中,并且不能最大化.第二个应在第二个监视器中启动(一个完美的示例就像PowerPoint的演示模式一样),它在任何其他应用程序窗口的顶部"运行,并且始终处于最大化状态.该窗口是使用指定给第一个窗口的侦听器启动的.请注意,这些监视器"可以是演示文稿中使用的LCD投影仪,也可以是真正的台式计算机监视器.

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.

我知道存在GraphicsEnvironment API,并且我们可以知道我们的监视器配置是作为单个监视器还是作为单独的监视器来对待.但是,我不知道如何实现它.我的意思是,由于屏幕配置可以根据其图形卡而有所不同,因此我们如何验证它们?

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?

例如,如果将3台显示器视为高分辨率的单个显示器,则也许我们可以将第二个窗口的坐标x0设置为:total_width * 2/3.但是,如果将其作为单独的监视器怎么办呢??

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..?

谢谢.

推荐答案

@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:

GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();

之后,只需使用:

gs[_screen_index].setFullSCreenWindow(_frame)

这篇关于如何在多监视器配置中部署JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 14:35