title: JPanel draws itself underneath JFrame title bar
body: <p>I have a 500 by 500-pixel image that I'm trying to draw onto a JPanel which lives inside a JFrame. Here's the code I have so far:</p>
  
  <pre><code>public class Game extends JFrame {
      // Other code...
  
     setTitle("Game");
  
     JPanel panel = new JPanel();
     panel.setPreferredSize(new Dimension(500, 500));
  
     add(panel);
     setSize(500, 500);
  
     setIgnoreRepaint(true);
  
     // Handle a close event gracefully.
     addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
             System.exit(0);
         }
     });
  
     addKeyListener(new MainMenuState(this));
  
     setResizable(false);
     pack();
     setVisible(true);
  </code></pre>
  
  <p>I can draw to the JPanel okay but it appears that the JPanel's top left corner is being drawn at 0,0 on the JFrame, which is underneath the title bar. I've tried setting layout managers on the JFrame but that didn't seem to work. I could manually offset the JPanel but I don't think I have to do that (I thought <code>pack()</code> was supposed to take car of that).</p>