Search code examples
javaswinguser-interfaceusability

How to identify the monitor from Java Swing application?


I wrote a swing application for my clients and some of them are using multiple monitors. Unfortunately that Java Swing application is confused in environment where multiple monitors present and pop up window appear in either first or second window. How can I identify that client has multiple monitors and force application to show up consistently on one monitor?


Solution

    1. To detect number of screens, use GraphicsEnvironment.getScreenDevices().
    2. To specify the monitor, either refer to this question, or the example in the GraphicsDevice API.