title: "Internal error: couldn't create component peer"
body: <p>I keep INTERMITTENTLY having this error when I start my game:</p>
  
  <pre><code>Exception in thread "main" java.lang.InternalError: couldn't create component peer
  at sun.awt.windows.WComponentPeer.checkCreation(Unknown Source)
  at sun.awt.windows.WComponentPeer.&lt;init&gt;(Unknown Source)
  at sun.awt.windows.WCanvasPeer.&lt;init&gt;(Unknown Source)
  at sun.awt.windows.WPanelPeer.&lt;init&gt;(Unknown Source)
  at sun.awt.windows.WWindowPeer.&lt;init&gt;(Unknown Source)
  at sun.awt.windows.WFramePeer.&lt;init&gt;(Unknown Source)
  at sun.awt.windows.WToolkit.createFrame(Unknown Source)
  at java.awt.Frame.addNotify(Unknown Source)
  at java.awt.Window.show(Unknown Source)
  at java.awt.Component.show(Unknown Source)
  at java.awt.Component.setVisible(Unknown Source)
  at java.awt.Window.setVisible(Unknown Source)
  at Joehot200.TerrainDemo.setUpDisplay(TerrainDemo.java:3569)
  at Joehot200.TerrainDemo.startGame(TerrainDemo.java:3640)
  at StartScreenExperiments.Test2.resartTDemo(Test2.java:55)
  at StartScreenExperiments.Test2.main(Test2.java:41)
  </code></pre>
  
  <p>I am unable to reproduce it, and it appears to simply happen randomly when I start the game - Sometimes, it starts fine, and other times, it has that error.</p>
  
  <p>I'm initiating the display with this code:</p>
  
  <pre><code>private void setUpDisplay() {
      //System.setProperty("org.lwjgl.librarypath", new File("D:/Downloads/mcp/ship/Ship/lib/natives-win").getAbsolutePath());
      try {
          DisplayMode displayMode = null;
          DisplayMode[] modes = Display.getAvailableDisplayModes();
  
           for (int i = 0; i &lt; modes.length; i++)
           {
               if (modes[i].isFullscreenCapable())
                 {
                      displayMode = modes[i];
                 }
           }
           if (displayMode == null){
               displayMode = new DisplayMode(100, 100);
           }
           displayMode = Display.getDesktopDisplayMode();
           //Display.setDisplayModeAndFullscreen(new DisplayMode(200, 200));
          //Display.setDisplayMode(new DisplayMode(WINDOW_DIMENSIONS[0], WINDOW_DIMENSIONS[1]));
           Display.setDisplayMode(displayMode);
          Display.setResizable(true);
          Display.setTitle("Pirate game");
          //Display.setFullscreen(true);
          try {Thread.sleep(3000);} catch (InterruptedException e1) {}
  
          frame = new JFrame();
  
          Canvas canvas = new Canvas();
          frame.add(canvas);
          frame.setSize(500, 500);
          frame.setVisible(true);
          try {
              try {Thread.sleep(3000);} catch (InterruptedException e1) {}
              Display.setParent(canvas);
  
              Display.create();
  
          } catch (LWJGLException e) {
              e.printStackTrace();
          }
          try {Thread.sleep(3000);} catch (InterruptedException e1) {}
          frame.setVisible(true);
          frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
          frame.repaint();
  
      } catch (LWJGLException e) {
          e.printStackTrace();
          //cleanUp(true);
      }
  }
  </code></pre>
  
  <p>Obviously it is something to do with the JFrame being created (since if I make the display without the JFrame it works fine), however I am currently unable to solve the issue (without ditching JFrames, which I can't do).</p>
  
  <p>I am unsure if the issue has anything to do with LWJGL/OpenGL, so I have tagged it as such anyway.</p>