title: Component must have a valid peer - BufferStrategy
body: <p>First off all, I know questiones like this has been asked before, but no answers seem to fix my problem.</p>
  
  <p>I am working on a little game, and for some reason java returns an IllegalStateException whenever I try to create a new bufferstrategy. I am adding the game to a JFrame,  but the exception is still thrown, here is the code for adding to the JFrame:</p>
  
  <pre><code>JFrame frame;
  
  
  public Window(int x, int y, int width, int height, String title, boolean focus, Main game) throws IOException {
          frame = new JFrame();
          frame.setLocation(x, y);
          frame.setSize(new Dimension(width, height));
          frame.setTitle(title);
          frame.add(game);
          game.start();
          frame.setAutoRequestFocus(focus);
          frame.setFocusable(true);
          frame.setVisible(true);
      }
  </code></pre>
  
  <p>And here is the code for creating the window (located in the Main class):</p>
  
  <pre><code>window = new Window(x, y, WIDTH, HEIGHT, "Title", true, this);
  </code></pre>