I am collecting the screen devices of a multi-monitor environment in Java and would like to know which of these screen devices is the default screen device.
The code device.getIDString()
returns "\Display0" and so forth for each monitor, so I could simply say something along the lines of .contains("0")
, but not only is this inelegant, but also I suspect that the format will be different across different vendors or operating systems.
答案 0 :(得分:2)
The Javadoc recommends this:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = ge.getDefaultScreenDevice();
http://docs.oracle.com/javase/7/docs/api/java/awt/GraphicsEnvironment.html#getDefaultScreenDevice()