public static void setFullScreen(boolean fullScreen) {
setFullScreen(fullScreen, true);
}
private static void setFullScreen(boolean fullScreen, boolean visible) {
GraphicsDevice graphicsDevice = windowedHostFrame.getGraphicsConfiguration().getDevice();
if (fullScreen) {
// Go to full screen mode
if (windowedHostFrame.isVisible()) {
windowedHostFrame.remove(primaryDisplayHost);
}
windowedHostFrame.setVisible(false);
// Setting the full screen window now will cause a SplashScreen to
// be dismissed, so don't do so if the --preserveSplashScreen
// startup property was true, and a SplashScreen was supplied.
// When the SplashScreen needs to be dismissed, users can call
// replaceSplashScreen(Display) which will set the full screen
// window, if required.
if (visible) {
graphicsDevice.setFullScreenWindow(fullScreenHostFrame);
}
fullScreenHostFrame.add(primaryDisplayHost);
fullScreenHostFrame.setTitle(windowedHostFrame.getTitle());
fullScreenHostFrame.setVisible(visible);
} else {
// Go to windowed mode
if (fullScreenHostFrame.isVisible()) {
fullScreenHostFrame.remove(primaryDisplayHost);
}
fullScreenHostFrame.setVisible(false);
graphicsDevice.setFullScreenWindow(null);
windowedHostFrame.add(primaryDisplayHost);
windowedHostFrame.setTitle(fullScreenHostFrame.getTitle());
windowedHostFrame.setVisible(visible);
}