While this should normally be enough to show a fullscreen window (methods order is important!):
public class FullscreenWindow
{
public static void main ( final String[] args )
{
SwingUtilities.invokeLater ( new Runnable ()
{
@Override
public void run ()
{
final JFrame frame = new JFrame ();
frame.setExtendedState ( JFrame.MAXIMIZED_BOTH );
frame.setUndecorated ( true );
frame.setVisible ( true );
}
} );
}
}
It is not enough to make your system recognize that window as a truly fullscreen. Whether you need that or not is up to you though since truly fullscreen window has it's own pros and cons.
To make any Window
an actual fullscreen window in your system - you need to pass it into graphics device like this:
public class FullscreenWindow
{
public static void main ( final String[] args )
{
SwingUtilities.invokeLater ( new Runnable ()
{
@Override
public void run ()
{
final JFrame frame = new JFrame ();
frame.setExtendedState ( JFrame.MAXIMIZED_BOTH );
frame.setUndecorated ( true );
frame.setVisible ( true );
frame.getGraphicsConfiguration ().getDevice ().setFullScreenWindow ( frame );
}
} );
}
}
Graphics device basically represents a single screen device you have attached to your PC, obviously there could be more than one.
While the example above will only make your window fullscreen on it's current graphics device (screen that window is mostly placed on), you can make your window fullscreen on any other available graphic device as well.
You can retrieve full list of available graphics devices like this:
GraphicsDevice[] screenDevices = GraphicsEnvironment.getLocalGraphicsEnvironment ().getScreenDevices ();
You can also request actual sizes from the graphics devices and their relative locations to each other to better understand how user's screens are positioned (configured in system settings) relative to each other.