Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get numbers of monitors

Tags:

java

swing

awt

There are 2 monitors attached to my computer and I want to count them programmatically. How to do that with Java?

like image 413
Ravi_Parmar Avatar asked Aug 07 '14 10:08

Ravi_Parmar


People also ask

How do I number my monitors?

You simply click on the monitor that you want to be the primary monitor in settings>display, and then scroll down and select the box that says "Make this my main display".

How do you number multiple monitors?

To change the monitors' position, click, drag, and place the blue, numbered boxes to your preferred position. If you are unsure which monitor is "1" or "2," click the "Identify" link. The assigned monitor number will then appear on each monitor's screen. When finished, click [Apply].


1 Answers

Try next:

GraphicsEnvironment localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
System.out.println(localGraphicsEnvironment.getScreenDevices().length);
like image 122
alex2410 Avatar answered Oct 13 '22 01:10

alex2410