Making a Java panel fullscreen

clamp picture clamp · Feb 27, 2010 · Viewed 31.2k times · Source

How would you make a JComponent (panel, frame, window, etc.) fullscreen, so that it also overlaps everything on the screen including the windows start bar?

I don't want to change the resolution or anything with the graphics device like bitdepth etc, I just want to overlap everything else.

Answer

Adamski picture Adamski · Feb 27, 2010

Check out this tutorial describing Java's Full-Screen mode API.

Example code (taken from the tutorial). Note that the code operates on a Window so you would need to embed your JPanel with a Window (e.g. JFrame) in order to do this.

GraphicsDevice myDevice;
Window myWindow;

try {
    myDevice.setFullScreenWindow(myWindow);
    ...
} finally {
    myDevice.setFullScreenWindow(null);
}