problem and exception while changing polygon mode

In a demo app of mine I want to switch the polygon mode with glPolygonMode between LINES and FULL. To make things easy I added a KeyListener to the GLCanvas. I declared a (volatile) variable polyMode that is set by the listener method and used by a call to glPolygonMode(…) which is the first operation of GLEventListener.display(…).

Now something strange happens:
a)
Initially the polygonmode is set to lines. After successfully changing to FULL-mode the app doesn’t get back to LINE mode although the controlling variable is set.

b)
When having gl.glPolygonMode() in display() resizing of the windows fails with the following exception:


net.java.games.jogl.GLException: glGetError() returned the following error codes after a call to glViewport(): GL_INVALID_ENUM 
        at net.java.games.jogl.DebugGL.checkGLGetError(DebugGL.java:9741)
        at net.java.games.jogl.DebugGL.glViewport(DebugGL.java:8974)
        at net.java.games.jogl.GLCanvas$1.run(GLCanvas.java:121)
        at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:189)
        at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:196)
        at net.java.games.jogl.GLCanvas.display(GLCanvas.java:91)
        at net.java.games.jogl.Animator$1.run(Animator.java:104)
        at java.lang.Thread.run(Thread.java:534)

Here the code that is directly called by an anonymouse KeyListener:


      private void keyPressed(int keyCode){
            switch(keyCode){
                  case KeyEvent.VK_F:
                        polyMode = (polyMode == GL.GL_LINES) ? GL.GL_FILL : GL.GL_LINES;
                        break;
            }
      }

And this is my display-Method:


public void display(GLDrawable glDrawable) {
            gl.glPolygonMode(GL.GL_FRONT, polyMode);
            
            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
            gl.glLoadIdentity();

            gl.glTranslated(0, 0, zoom);
            
            wheel.paint(gl);
      }

I am using JOGL from July 18th (Windows version).

Does anyone know what I am doing wrong or how to solve polygon mode switching problem?

Thanks in advance.

I can admit the following:
Not using the DebugGL helps against the exception but now an OpenGL errorcode gets lost.

However switching back to LINE mode does not work …

The correct constant to use is GL_LINE, not GL_LINES.

Thank you.
That solved it.