automatically switch to fullscreen

This commit is contained in:
2025-12-08 06:18:03 +01:00
parent afcc32dc9f
commit b4d07b0d99
2 changed files with 13 additions and 1 deletions

View File

@@ -6,12 +6,14 @@ import java.util.logging.Logger;
public class Boot {
public static final Logger logger = Logger.getLogger("JDGame2D");
public static JFrame window;
static void main() {
JFrame window = new JFrame();
window = new JFrame();
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
window.setResizable(false);
window.setTitle("JGame2D");
window.setUndecorated(true);
GamePanel gamePanel = new GamePanel();
window.add(gamePanel);

View File

@@ -222,6 +222,16 @@ public class GamePanel extends JPanel implements Runnable {
tempScreen = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB);
fg2 = (Graphics2D) tempScreen.getGraphics();
setFullscreen();
}
public void setFullscreen() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
gd.setFullScreenWindow(Boot.window);
fScreenWidth = Boot.window.getWidth();
fScreenHeight = Boot.window.getHeight();
}
}