Login  Register

Re: key input Keylistener doesn't work for JOGL

Posted by tragic_xxx on Nov 08, 2017; 12:46pm
URL: https://forum.jogamp.org/key-input-Keylistener-doesn-t-work-for-JOGL-tp4038300p4038302.html

gouessej wrote
Hi

If the GLCanvas receives the key events, the key listener will have to be added to it instead of the JFrame, it's a basic Swing problem, it's not a JOGL problem. You could have the same kind of problem in a 2D game using only AWT, you have to put the key listener into the right component.

By the way, replace new GLU() by GLU.createGLU(GL) in order to use a more capable instance of GLU. glFlush is probably useless here.

Good luck.
Thank you for reply.  Can you elaborate further, I am rather new to these particular APIs.
How do I add the KeyListener to JFrame correctly (in this context)?
I tried to use GLU.createGLU(GL) instead of GLU(), but I must have written the wrongly because I had errors. So  how do I replace GLU() correctly?
Is it possible that you write the corrections over the original code and paste it in a reply? I will learn better that way.

Many thanks in advance