Share this page 

Maximize a JFrameTag(s): Swing


import java.awt.*;
import javax.swing.*;

public class TestMaxJFrame extends JFrame {
  public TestMaxJFrame() {
   GraphicsEnvironment env =
     GraphicsEnvironment.getLocalGraphicsEnvironment();
   /*
     The next line determines if the   taskbar (win) is covered
     if unremarked, the task will not be covered by
     the maximized JFRAME.
   */
   // this.setMaximizedBounds(env.getMaximumWindowBounds());
   this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);
  }

  public static void main(String[] args) {
   JFrame.setDefaultLookAndFeelDecorated(true);
   TestMaxJFrame t = new TestMaxJFrame();
   t.setVisible(true);
  }
}