0

在应用程序的某个时刻,我需要获取可用屏幕的整个区域(没有工具栏,在 Windows 8 中,并排应用程序)。这是通过调用

      GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();

或者,如果你想直接做

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

(这与 SunGraphicsEnviroment 执行第一个操作的方式完全相同)。

我遇到的问题是,当我在单屏上时, getScreenInsets() 正确地考虑了并排应用程序(得到类似 java.awt.Insets[top=0,left=971 ,底部=48,右侧=0])。但是,如果我在多屏幕环境中,两个屏幕都会显示 left = 0 的插图 (java.awt.Insets[top=0,left=0,bottom=60,right=0])

getInsets 应该与多屏不同地使用,还是这是一个 Java 问题?我正在使用 1.7v40。我也没有在 Oracle 错误数据库上找到类似的东西。

4

1 回答 1

0

回答自己:是的。这是一个 Java 错误

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

如果您需要这样做,则需要使用本机代码并使用 Windows API 或等待 Java 补丁。

于 2014-03-28T20:29:30.493 回答