Re: key input Keylistener doesn't work for JOGL
Posted by
gouessej on
Nov 09, 2017; 10:10am
URL: https://forum.jogamp.org/key-input-Keylistener-doesn-t-work-for-JOGL-tp4038300p4038308.html
Maybe you should have looked at the simple examples in the wiki.
Replace "
this.addKeyListener(this);" by "
canvas.addKeyListener(this);".
You can create the GLU instance in the method GLEventListener.init(GLAutoDrawable):
@Override
public void init(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
glu = GLU.createGLU(gl);
I disagree with your answer to jmaasing. You must understand the concepts before applying them, otherwise you will just tinker some source code that you don't really understand. I simply advised you to add the key listener to the canvas rather than to the frame; if you don't succeed in understanding that it means that you have to modify just a single line of code to achieve this, it means that you don't even understand the source code you originally posted. We didn't speak to you only about the theory, we explained to you how to fix your code and why it works. Moreover, the Oracle tutorials are very well written, they explain the concepts and they contain numerous examples (including full source code most of the time), it's not just about theory. I'm sure that if you try to learn too much things too fast, you'll fail. There are no shortcomings, neither in Swing nor in computer graphics in general.
In my humble opinion, giving you the fixed source code without being sure that you understand both the original one and the fixed one instead of giving you the fixes with the necessary explanations is a bad solution and leads to spoon-feeding. We weren't born experts, we became experts, keep it in mind.