Java setFullScreenWindow()保持在最顶层 [英] Java setFullScreenWindow() keep on top
问题描述
我正在编写一个旨在双显示器设置上运行的应用程序,其中DisplayJFrame在一台显示器上全屏显示,另一台显示器上显示ControlJFrame,向显示器发送指令。我尝试了两种不同的方法来设置全屏显示;每个人的成功似乎取决于操作系统。
display.setUndecorated(true);
display.setExtendedState(JFrame.MAXIMIZED_BOTH);
适用于Windows,但JFrame隐藏在OS X和Linux的dock / panels下。 / p>
我的另一种方法,利用
GraphicsDevice.setFullScreenWindow(display);
适用于我尝试的所有三个操作系统,但在Windows中,将控制窗口聚焦在另一台显示器上使显示窗口隐藏,并调用
display.setAlwaysOnTop(true);
无法解决问题。我有点偏向 GraphicsDevice
方法,因为我不必处理OS X或Linux中的问题,我希望Windows的问题是一个简单的修复。是吗?
试试这个......
对于多屏幕
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice [] gs = ge.getScreenDevices();
//获取每个屏幕的大小
for(int i = 0; i< gs.length; i ++){
DisplayMode dm = GS [I] .getDisplayMode();
int screenWidth = dm.getWidth();
int screenHeight = dm.getHeight();
}
使用 public final void setAlwaysOnTop(boolean alwaysOnTop)
用于将窗口置于顶部,如果窗口可见,则包括将窗口带到前面
,然后将其粘贴到最顶端的位置。
I'm writing an application that is intended to be run on a dual monitor setup, with a "Display" JFrame going fullscreen on one monitor and a "Control" JFrame on the other monitor, sending instructions to the Display. I've tried two separate methods of setting the Display fullscreen; the success of each seems to depend on the OS.
display.setUndecorated(true);
display.setExtendedState(JFrame.MAXIMIZED_BOTH);
Works in Windows, but the JFrame gets hidden under the dock/panels in OS X and Linux.
My other method, utilizing
GraphicsDevice.setFullScreenWindow(display);
Works in all three OSes that I tried, but in Windows, focusing the Control window on the other monitor makes the Display window hide, and calling
display.setAlwaysOnTop(true);
Doesn't fix the problem. I'm kind of partial to the GraphicsDevice
method because I don't have to deal with the issues in OS X or Linux, and I'm hoping that the Windows problem is a simple fix. Is it?
Try this...
For Multiple Screen
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
// Get size of each screen
for (int i=0; i<gs.length; i++) {
DisplayMode dm = gs[i].getDisplayMode();
int screenWidth = dm.getWidth();
int screenHeight = dm.getHeight();
}
Use public final void setAlwaysOnTop(boolean alwaysOnTop)
for putting the window on top, If the window is visible, this includes bringing window toFront
, then "sticking" it to the top-most position.
这篇关于Java setFullScreenWindow()保持在最顶层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!