在应用程序的某个时刻,我需要获取可用屏幕的整个区域(没有工具栏,在 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 错误数据库上找到类似的东西。