title: JOGL: javax.media.opengl.GLException: AWT-EventQueue-0: Context not current on thread
body: <p>I'm creating a game with JOGL and I've come across an error which I can't for the life of me figure out. </p>
  
  <p>In the game I'm using two GLCanvases (GLJpanels actually), one for the menu and one for the actual game. The idea being that when a game is started from the menu, the menu GLCanvas is removed from the gamewindow and swapped for the game GLCanvas. So far I've gotten the menu to work pretty much perfectly, but whenever I attempt to switch over to the game canvas, I get this error:</p>
  
  <pre><code>Catched Exception on thread AWT-EventQueue-0
  javax.media.opengl.GLException: AWT-EventQueue-0: Context not current on thread, obj 0x2ab44e2d, ctx 0x0, surf 0x0, inDestruction: false, &lt;53f7c06e, 2e7aa0d3&gt;[count 0, qsz 0, owner &lt;NULL&gt;]
  </code></pre>
  
  <p>The code I'm using to switch between canvases is:</p>
  
  <pre><code>public void start()
  {
      canvas.addGLEventListener(this);
      animator.start();
      window.add(canvas);
      canvas.requestFocus();
  }
  public void stop()
  {
      window.remove(canvas);
      animator.stop();
      canvas.removeGLEventListener(this);
  }
  </code></pre>
  
  <p>and the switch function:</p>
  
  <pre><code>public void switchToCanvas(String canvasName)
  {
      currentCanvas = canvasName;
  
      if(canvasName.equals("GameCanvas"))
      {
          menu.stop();
          game.start();
      }
      else
      {
          game.stop();
          menu.start();
      }
  }
  </code></pre>
  
  <p>I've done some googling and I came around this question: <a href="https://stackoverflow.com/questions/7420027/jogl-how-can-i-create-my-own-opengl-context-and-bind-it-to-a-glcanvas">How can I create my own openGL context and bind it to a GLCanvas?</a></p>
  
  <p>But none of the solution posted there worked for me. </p>