0

My system monitoring app takes screenshot every five minutes it runs in a system. But for a system connected in dual monitor mode needs a different set of codes to take the complete 180 degree screenshot.

Is there a way to know if the system is working in dual monitor mode by some means(system property)?

Ananthu K Kumar
  • 86
  • 2
  • 10
  • 1
    I guess you could use "GraphicsEnvironment" class and something like below: GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); screens = ge.getScreenDevices() https://docs.oracle.com/javase/6/docs/api/java/awt/GraphicsDevice.html – Rukshán Dikovita Jul 15 '21 at 05:21
  • @Rukshán This worked. – Ananthu K Kumar Jul 15 '21 at 05:49

1 Answers1

4

you can use GraphicsEnvironment https://docs.oracle.com/javase/7/docs/api/java/awt/GraphicsEnvironment.html :

private String getMonitorSizes() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[]    gs = ge.getScreenDevices();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < gs.length; i++) {
        DisplayMode dm = gs[i].getDisplayMode();
        sb.append(i + ", width: " + dm.getWidth() + ", height: " + dm.getHeight() + "\n");
    }
    return sb.toString();
}
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Uday Chauhan
  • 1,071
  • 1
  • 9
  • 19