Search code examples
javaswinguser-interfacemultiple-monitors

Determine the GraphicsConfiguration of a JFrame?


I know I can display a JFrame on different monitors / GraphicsConfiguration / devices but what about doing the inverse: is it possible, from a JFrame's reference, to find to which GraphicsConfiguration it is attached?

As a side-question: is it possible for me to start a JFrame by passing a specific GraphicsConfiguration and then have the user somehow move the JFrame to another GraphicsConfiguration? (if it's not possible for the user to do such a thing then I take it that I could just track to which GraphicsConfiguration I attach in the first place and so I can always find that information back anyway)


Solution

  • You can use following code to find which GraphicsConfiguration is used:

    frame.getGraphicsConfiguration();
    

    To set your GraphicsConfiguration you can use Frame f= new JFrame(gc);