I have 2 displays connected, so I can either launch my Java application on the primary or the secondary display.
The question is: How can I know which display contains my app window, i.e., is there a way to detect the current display with Java?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
java.awt.Window is the base class of all top level windows (Frame, JFrame, Dialog, etc.) and it contains the
getGraphicsConfiguration()method that returns the GraphicsConfiguration that window is using. GraphicsConfiguration has thegetGraphicsDevice()method which returns the GraphicsDevice that the GraphicsConfiguration belongs to. You can then use the GraphicsEnvironment class to test this against all GraphicsDevices in the system, and see which one the Window belongs to.