开发者

How to deploy a JFrame in multiple monitor configuration

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 l开发者_StackOverflowarge 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.


@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();

After that, just use:

gs[_screen_index].setFullSCreenWindow(_frame)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜