I am trying to display two JFrames, one on each monitor, and the code seems to output the wrong stuff. My question is border line similar to these...
Question 1
Question 2
Question 3
Except mine has to do with the JFrames basically being overridden and showing up blank. Sample code below from one of the questions that I was testing to see if it is what I wanted, but the JFrames show up nothing like I want. They are blank, even though they are supposed to display Icons. The code is bare, as I am trying to figure out why the JFrames become re-sizable, and don't exit like they are supposed to.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Dual extends JFrame implements ActionListener, ChangeListener {
public Dual(String one) {
JFrame frame = new JFrame(one);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setResizable(false);
}
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" );
}
}
public static void main(String[] args) {
showOnScreen(1, new Dual("Test"));
showOnScreen(2, new Dual("1...2"));
GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
for ( int i = 0; i < devices.length; i++ ) {
System.out.println( "Device " + i + " width: " + devices[ i ].getDisplayMode().getWidth() );
System.out.println( "Device " + i + " height: " + devices[ i ].getDisplayMode().getHeight() );
}
}
}