I'm creating an application that can run on two monitors. For that I created 2 JFrames. The first is my client application that will display information only i have to see. The second (lets call it TweetForm) is a jframe that will show information everybody can see. (probable monitor will be a TV). I've searched how to put this on two seperate screens and found the following solution: Show JFrame in a specific screen in dual monitor configuration
this works just fine, BUT: whenever i'm focus something on my 'mainmonitor' the tweetForm which is displaying on the TV gets minimized. How can I prevent the jframe from minimizing and always be displayed? (even though the first jframe is minimized or not)
CODE FROM 2nd JFRAME
/**
* Creates new form TweetForm
*/
public TweetForm()
{
initComponents();
dispose();
setUndecorated(true);
pack();
setExtendedState(Frame.MAXIMIZED_BOTH);
setTitle("Serious Request");
this.setAlwaysOnTop(true);
showOnScreen(1, this);
}
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" );
}
}
Use only one JFrame
. Make the other one as JDialog
and update data in dialog with respect to you frame.
Also see,