简体   繁体   English

在Java + Windows 8上,使用并行应用程序和多屏屏幕时如何获得可用的屏幕边框?

[英]On Java + windows 8, how do you get useable screen borders when using side-by-side apps and multiscreen?

At some point in an application, I need to get the whole area of a screen that is useable (without toolbars, and in Windows 8, side-by-side apps). 在应用程序中的某个点上,我需要获得可用屏幕的整个区域(没有工具栏,并且在Windows 8中,并排应用程序)。 That is done by either calling 通过调用

      GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();

or, if you want to do it directy 或者,如果您想直接进行

 GraphicsConfiguration gc = myGraphicsDevice.getDefaultConfiguration();
    Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
    Rectangle usableBounds = gc.getBounds();
    usableBounds.x += insets.left;
    usableBounds.y += insets.top;
    usableBounds.width -= (insets.left + insets.right);
    usableBounds.height -= (insets.top + insets.bottom);

(which, is the exact same way in which SunGraphicsEnviroment performs the first operation). (这与SunGraphicsEnviroment执行第一个操作的方式完全相同)。

The problem I'm having is that, when I'm on single-screen, getScreenInsets() correctly take the side-by-side app into account (getting a result like java.awt.Insets[top=0,left=971,bottom=48,right=0]). 我遇到的问题是,当我在单屏幕上时,getScreenInsets()正确地考虑了并排应用程序(得到类似java.awt.Insets [top = 0,left = 971的结果,底部= 48,右侧= 0])。 However, if I'm in a multiscreen enviroment, BOTH screens show insets with left = 0 (java.awt.Insets[top=0,left=0,bottom=60,right=0]) 但是,如果我处于多屏幕环境中,则两个屏幕都显示左= 0的插图(java.awt.Insets [top = 0,left = 0,bottom = 60,right = 0])

Should getInsets used differently with multiscreen, or is this a Java problem? getInsets是否应与多屏屏幕不同地使用,或者这是Java问题吗? I'm using 1.7v40. 我正在使用1.7v40。 I haven't found anything like this on the Oracle bug database, either. 我也没有在Oracle错误数据库中找到类似的东西。

Answering myself: yes. 回答自己:是的。 It is a Java Bug 这是一个Java错误

http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6899304 http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6899304

If you need to do that, you need to go down to native code and use the Windows API or wait for a Java patch. 如果需要这样做,则需要使用本机代码并使用Windows API或等待Java补丁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM