title: Maximizing JFrame in Java
body: <p>There have been several questions related to this, for example <a href="https://stackoverflow.com/questions/11570356/jframe-in-full-screen-java">here</a> and <a href="https://stackoverflow.com/questions/479523/jframe-maximize-window">here</a>, that both say the way to maximize a <code>JFrame</code> is to use the following code:</p>
  
  <pre><code>frame.setExtendedState(JFrame.MAXIMIZED_BOTH); //Some answers have these lines
  frame.setVisible(true);                        //reversed
  </code></pre>
  
  <p>However, for me, not sure if this is a windows 10 bug/java 8 bug or not, when I use this code the result is this (no matter which way round the two lines of code above are):</p>
  
  <p><a href="https://i.stack.imgur.com/sKTGd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sKTGd.png" alt="Offset &lt;code&gt;JFrame&lt;/code&gt;"></a></p>
  
  <p>As you can see in the image, the window is the correct size, however, it slightly overlays the bottom, and it is slightly offset from the left. Is there a way to fix this problem, or actually maximise the program by hitting the maximise button on the <code>JFrame</code> with code?</p>
  
  <p><strong>Edit</strong><br>
  Here is a MCVE that demonstrates the problem:</p>
  
  <pre><code>import java.awt.GridLayout;
  import javax.swing.JFrame;
  
  public class CDBurner extends JFrame {
      private static final long serialVersionUID = -6027473114929970648L;
  
      private CDBurner() {
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setLayout(new GridLayout(1, 1));
          setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
          setVisible(true);
          setLocationRelativeTo(null);
          requestFocus();
      }
  
      public static void main(String[] args) {
          new CDBurner();
      }
  }
  </code></pre>