我使用以下代码来检查有多少个屏幕,并选择最大的一个来显示我的应用程序。然而,我还没有成功地检测到显示器被镜像而不是扩展的情况。有什么办法可以做到这一点吗?
if (GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length > 1) {
findBiggestScreen(GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()).setFullScreenWindow(this);
} else {
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this);
}
最佳答案
我无法测试这个,因为我没有第二个显示器可用,但也许你可以尝试 GraphicsDevice#getDefaultConfiguration()#getBounds() .
javadoc 中没有明确提及,但我猜镜像屏幕的 x 和 y 偏移量具有相同的值。
关于java - 如何使用GraphicsEnvironment检测显示镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10106539/