In my application, I have 2 windows (jframe), one for controlling and one for displaying things (like powerpoint presentation mode).
How can I specify one window is opened in screen no. 1 and the other is opened in screen no. 2 when I start the application?
The method below somehow works, but the thing is the window on the second screen always maximized and I don't want it to be maximized. But it seems the only way to connect GraphicsDevice and JFrame is the function called setFullScreenWindow.
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" );
}
}
You can define a JFrame with a GraphicsDevice.
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for (int j = 0; j < gs.length; j++) {
JFrame f = new JFrame(gs[j].getDefaultConfiguration());
// Rest of the code
}