I’m writing some code in Java that needs to show file chooser and alert dialogs. These dialogs always need to show up on a second monitor, rather than the main monitor.
If the application were entirely written in Java/Swing, these dialogs would be positioned relative to the application’s main JFrame, and so would show up on the second monitor if that was the location of the main frame. In this application, however, the main window is created by native code. So Java doesn’t know the location of the main window, and can’t position its dialogs relative to it.
Is there a way that I can tell Java to show dialogs on the second monitor by default? (perhaps by changing some of the Look and Feel?)
“In a multi-screen environment, the
GraphicsConfigurationobjects can be used to render components on multiple screens.”—GraphicsDevice. See also the Full-Screen Exclusive Mode API tutorial.