First I should note that my dual monitors are in custom position rather than the default left-to-right.
I was attempting to create a full-screen exclusive mode game, but in testing I noticed that when I used EXIT_ON_CLOSE (and in System.exit), that the monitor setup would be reset to the default left-to-right. But when I used DISPOSE_ON_CLOSE (and for just a dispose()) it would be perfectly normal when returning to my desktop. Is this acceptable practice, or is there something I'm missing?
Relevant part:
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class FullScreenTest extends JFrame {
public FullScreenTest() {
GraphicsDevice screen = GraphicsEnvironment.
getLocalGraphicsEnvironment().getDefaultScreenDevice();
add(new JLabel("Test"));
setDefaultCloseOperation(EXIT_ON_CLOSE);
screen.setFullScreenWindow(this);
}
public static void main(String[] args) {
FullScreenTest test = new FullScreenTest();
}
}
have look at official tutorial Full-Screen Exclusive Mode API
few examples to the tutorials methods about GraphicsEnvironment
and GraphicsDevice
But when I used
DISPOSE_ON_CLOSE
(and for just a dispose()) it would be perfectly normal when returning to my desktop
That is good. Stick with it. Many developers use EXIT_ON_CLOSE
when it is entirely unnecessary.
If DISPOSE_ON_CLOSE
does not work to end the JRE, it means that other GUI elements are still visible, or other non-daemon threads are running. In that case, it would generally be better to explicitly end the other threads, or check they can safely be ended.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.