Check out GraphicsEnvironment.getScreenDevices()
, you can get the screen bounding rectangles from each device, e.g.:
GraphicsDevice[] screens = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getScreenDevices();
for (GraphicsDevice screen:screens)
System.out.println(screen.getDefaultConfiguration().getBounds());
On my dual-monitor system it displays:
java.awt.Rectangle[x=0,y=0,width=1600,height=900]
java.awt.Rectangle[x=-320,y=-1200,width=1920,height=1200]
You can use getDefaultScreenDevice()
to figure out which one is the primary monitor. There's a lot of other info you can get from a GraphicsDevice
which might be useful.