Detect Which Screen Monitor Your Coordinates Belong To Using Java

Getting a screen’s size is simple using Toolkit class’ getScreenSize(). But what if you are working using more than 1 screen monitor, say a dual monitor? The ToolKit class won’t apply in this case. There are a few set of classes in Java that can do the trick namely GraphicsEnvironment and GraphicsDevice.

Let us say you have a coordinate and you want to know which screen monitor is belongs to (monitor 1 or monitor 2). This method will do just that.

Related Posts Plugin for WordPress, Blogger...

2 comments

  1. Your declaration for GraphicsDevice is missing a variable and GraphicsDevice needs to be set to an array b/c ge.getScreenDevices() returns an array of screen device objects.

    Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *