The solution is to set the frame’s width and height of the screen of the monitor dynamically according to the monitor settings. We can do this simply by writing the following code.
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); setSize(dimension);
A complete code is given below to make a full screen frame.
import javax.swing.JFrame; import java.awt.Toolkit; import java.awt.Dimension; public class FullscreenFrame extends JFrame { public FullscreenFrame() { Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); setSize(dimension); setTitle("A Fullscreen Frame"); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String args[]) { FullscreenFrame fullscreenFrame = new FullscreenFrame(); fullscreenFrame.setVisible(true); } }