title: Size of JFrame odd after pack()
body: <p>I have got this piece of code:</p>
  
  <pre><code>frame.setTitle("SideScroller");
  frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
  Dimension dim = new Dimension(1000, 500);
  frame.setContentPane(gamePanel);               //gamePanel is an extended JPanel
  gamePanel.setPreferredSize(dim);
  frame.pack();  
  </code></pre>
  
  <p>After I run this code and fill the <code>gamePanel</code> with parts of 50x50p, which should fill the <code>gamePanel</code> and thus the <code>frame</code> completely, there are some empty rows of pixels at the right and bottom of the screen. </p>
  
  <pre><code>frame.getSize();    //gives us: 1016 x 539
  frame.getInsets();  //gives: Top: 31 | Left: 8 | Bottom: 8 | Right: 8  
  </code></pre>
  
  <p>An image of the result:  </p>
  
  <p><img src="https://i.imgur.com/YRgPu3k.png" alt="JFrame after pack()"><br>
  As you can see, there is still some empty room in the <code>JFrame</code>.</p>
  
  <p>The code to fill the <code>gamePanel</code>:</p>
  
  <pre><code>//Fill the panel with landscape
  //One part : 50x50 px
  //Panel : 1000x500 px
  //Width : 20 prts
  //Height : 10 prts
  @Override
  public void paint(Graphics g){
      super.paint(g);
      for(int i = 0; i &lt; 20; i++){
          for(int j = 0; j &lt; 10; j++){
              //Decide which landscape-img should be used
              switch(levelOne[j][i]){
                  case 0:g.drawImage(new ImageIcon("resources\\landscape-img\\air.png")
                                      .getImage(), 50 * i, 50 * j, null);
                      break;
                  case 1:g.drawImage(new ImageIcon("resources\\landscape-img\\ground.png")
                                      .getImage(), 50 * i, 50 * j, null);
                      break;              
              }
          }
      }
      g.dispose();
  }
  </code></pre>
  
  <p>I do not see why the <code>frame</code> isn't filled fully. Hope someone can help me!</p>