Create a Full Screen JFrame
R. Kevin ColeNovember 11, 2003

Ever wanted to have a Kiosk-style JFrame running in full screen without a menu or title bar? You can do it by removing all decorations from the frame and setting its size to the screen size like this:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FullScreenJFrame extends JFrame
{
public FullScreenJFrame( String title )
{
super(title);

this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

setUndecorated(true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0,0,screenSize.width, screenSize.height);
getContentPane().add(new JLabel("A JFrame Kiosk"), BorderLayout.NORTH);
JButton closeButton = new JButton("Close");
closeButton.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent ae )
{
System.out.println("Close button Pressed");
FullScreenJFrame.this.setVisible(false);
System.exit(0);
}
});
getContentPane().add(closeButton, BorderLayout.CENTER);
}

public static void main( String[] args )
{
FullScreenJFrame frame = new FullScreenJFrame("");
frame.setVisible(true);
}
}