Java:未聚焦时,在第二个监视器中将窗口保持全屏显示 [英] Java: Keep window fullscreen in second monitor when not focused

查看:50
本文介绍了Java:未聚焦时,在第二个监视器中将窗口保持全屏显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个利用双监视器设置的Java应用程序.我有两个窗口:

I am writing a java application that takes advantage of a dual monitor set up. I have two windows:

  • 窗口1 -主GUI
  • 窗口2 -在第二台显示器上全屏显示
  • Window 1 - Main GUI
  • Window 2 - Full Screen on Second monitor

我的问题:只有焦点对准后,第二个窗口才保持全屏显示.如果我在窗口1上单击回来或将焦点更改为其他位置,则窗口2会最小化.是否有办法使窗口2在没有焦点时保持全屏显示?

My Problem: The second window only stays full screen when it has the focus. If I click back on window 1 or change the focus to something else, window 2 minimizes. Is there someway to make window 2 stay full screen when it doesn't have focus?

这是我的代码,用于在第二个监视器上使第二个窗口全屏显示:

Here is my code for making the second window full screen on the second monitor:

        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        frame.setUndecorated(true);
        frame.setVisible(true);
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gd = ge.getScreenDevices();
        gd[1].setFullScreenWindow(frame); //gets the 2nd display.

推荐答案

尝试获取第二个监视器的大小,然后设置第二个帧的大小,而不是设置全屏监视器.另外,尝试将第二帧设置为始终位于最上方.

Try getting the size of the second monitor then instead of setting the fullscreen monitor set the size of the the second frame. Also try setting the second frame to always on top.

这篇关于Java:未聚焦时,在第二个监视器中将窗口保持全屏显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆