I have a dual monitor config and I want to run my GUI in a specific monitor if it is found. I tried to create my JFrame
window passing a GraphicConfiguration
object of my screen device, but it doesn't work, frame still display on the main screen.
How can I set the screen where my frame must be displayed?
public static void showOnScreen( int screen, JFrame frame )
{
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
if( screen > -1 && screen < gs.length )
{
gs[screen].setFullScreenWindow( frame );
}
else if( gs.length > 0 )
{
gs[0].setFullScreenWindow( frame );
}
else
{
throw new RuntimeException( "No Screens Found" );
}
}