Jump to Real's How-to Main page

Maximize a JFrame

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);
  }
}

If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]