Java 如何识别屏幕设备是投影仪还是显示器

Java 如何识别屏幕设备是投影仪还是显示器,java,wmi,Java,Wmi,我想写一个wmi和Java,或两者兼有的程序,自动查找和识别连接到我的计算机(Windows)的显示器或投影仪 你知道怎么做吗?我不太清楚你想说什么,但希望这能帮助你 是所有顶级窗口(Frame、JFrame、Dialog等)的基类,它包含getGraphicsConfiguration()。GraphicsConfiguration具有getGraphicsDevice()方法,该方法返回GraphicsConfiguration所属的。然后可以使用该类对系统中的所有GraphicsDevic

我想写一个wmi和Java,或两者兼有的程序,自动查找和识别连接到我的计算机(Windows)的显示器或投影仪


你知道怎么做吗?

我不太清楚你想说什么,但希望这能帮助你

是所有顶级窗口(Frame、JFrame、Dialog等)的基类,它包含
getGraphicsConfiguration()。GraphicsConfiguration具有
getGraphicsDevice()
方法,该方法返回GraphicsConfiguration所属的。然后可以使用该类对系统中的所有GraphicsDevices进行测试,并查看该窗口属于哪一个

Window myWindow = ....
// ...
GraphicsConfiguration config = myWindow.getGraphicsConfiguration();
GraphicsDevice myScreen = config.getDevice();
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
// AFAIK - there are no guarantees that screen devices are in order... 
// but they have been on every system I've used.
GraphicsDevice[] allScreens = env.getScreenDevices();
int myScreenIndex = -1;
for (int i = 0; i < allScreens.length; i++) {
    if (allScreens[i].equals(myScreen))
    {
        myScreenIndex = i;
        break;
    }
}
System.out.println("window is on screen" + myScreenIndex);
windowmywindow=。。。。
// ...
GraphicsConfiguration config=myWindow.getGraphicsConfiguration();
GraphicsDevice myScreen=config.getDevice();
GraphicsEnvironment env=GraphicsEnvironment.getLocalGraphicsEnvironment();
//AFAIK-无法保证屏幕设备处于正常状态。。。
//但我用过的每一个系统都有。
GraphicsDevice[]allScreens=env.getScreenDevices();
int myScreenIndex=-1;
for(int i=0;i
见下文:


我非常确定,如果没有JNI/JNA支持,在Java中就无法做到这一点。您对使用WMI做了哪些研究?[1]:[2]:[3]:[4]:为什么不编辑您的答案并将链接放在那里?为什么要写评论?因为我是不被允许这样做的。我只能在Anwser中发布两个链接,这如何决定屏幕的设备类型?它如何区分项目和(LCD)显示器?我不知道这是怎么回答OP的问题的?