Note that there are some explanatory texts on larger screens.

plurals
  1. POJFrame in Dual Monitor System
    primarykey
    data
    text
    <p>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...<br> <a href="https://stackoverflow.com/questions/9179297/java-fullscreen-jframe-with-dual-monitor">Question 1</a><br> <a href="https://stackoverflow.com/questions/4627553/java-show-jframe-in-a-specific-screen-in-dual-monitor-configuration">Question 2</a><br> <a href="https://stackoverflow.com/questions/6748737/output-jframe-to-second-monitor-if-possible">Question 3</a><br> 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.</p> <pre><code>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 &gt; -1 &amp;&amp; screen &lt; gs.length ) { gs[screen].setFullScreenWindow(frame); } else if( gs.length &gt; 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 &lt; devices.length; i++ ) { System.out.println( "Device " + i + " width: " + devices[ i ].getDisplayMode().getWidth() ); System.out.println( "Device " + i + " height: " + devices[ i ].getDisplayMode().getHeight() ); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload