我有一个全屏java应用程序,它将在Windows 7计算机上的8监视器数字标牌类型显示器上运行。我需要能够在特定的物理监视器上显示内容。理想情况下,我希望在显示属性 - >中显示1-8的显示。设置,但是许多拔出/插入和重新排序的尝试都无法通过显示属性 - >设置以任何确定的顺序显示物理监视器。我可以对它们进行重新排序,但是当我的java程序在显示器上检索信息时,窗口中没有配置它们的布局/顺序。
GraphicsEnvironment ID返回诸如Device0和Device1之类的字符串,但这些字符串与显示属性中显示的Windows显示编号不匹配。例如,如果布局是7,4,1,2,3,4,5,6我仍然返回Device0,Device1 ...其中Device0对应于识别的屏幕1(而不是7,这是左边的第一个屏幕) )。有没有办法查询操作系统以确定显示器所处的布局和/或在特定物理监视器上显示全屏的其他技术?
答案 0 :(得分:3)
您可以获得相对于大虚拟桌面的屏幕范围:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (GraphicsDevice gd : ge.getScreenDevices()) {
Rectangle bounds = gd.getDefaultConfiguration().getBounds();
System.out.println(bounds.toString());
}
对于我的设置,这给出了:
java.awt.Rectangle[x=0,y=0,width=1280,height=1024]
java.awt.Rectangle[x=1280,y=304,width=1280,height=720]
您可以使用此信息来确定他们的订单。例如。如果您完全确定您的显示器处于一个漂亮的网格中,您可以在右上方的显示器上全屏显示:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gdUpperRight = null;
Rectangle bUpperRight = null;
for (GraphicsDevice gd : ge.getScreenDevices()) {
Rectangle b = gd.getDefaultConfiguration().getBounds();
if (bUpperRight == null || b.x > bUpperRight.x || b.y > bUpperRight.y) {
bUpperRight = b;
gdUpperRight = gd;
}
}
gdUpperRight.setFullScreenWindow(myFrame);