how to create a full screen window in java

This post of this java game development series walks you thru a way to create a full-screen application

Java game development series

Coding a full-screen app in java

To form a full-screen app you need to access the GraphicsDevice object. 

below is that, the code snippet to get a Graphics device object.

// get the graphics environment object
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// get the graphics device from ge
gd = ge.getDefaultScreenDevice();

Thru the GraphicsDevice object, we can set the JFrame window to full screen
by invoking its setFullScreenWindow(JFrame) method.

To switch from full screen to window mode the same method is used. For this we just pass a null - setFullScreenWindow(null);

FullScreenApp example on Github

By hitting the escape key you can close the app. 

Share this Post

Leave a Reply

Your email address will not be published. Required fields are marked *