Help with KeyListener in GLJPanel

I’m trying to have a GLEventListerner, MouseListener, and KeyListener on a GLJPanel. The GLeventListener and Mouse Listener work fine, but with KeyListener I’m having trouble. This is what I have.

I have a class:


public class XYPlot extends JInternalFrame {
        GLJPanel glcanvas;
        .......
        .......
        glcanvas.removeGLEventListener(xyInterface);
        glcanvas.addGLEventListener(xyInterface);
        glcanvas.removeMouseListener(xyInterface);
        glcanvas.addMouseListener(xyInterface);
        glcanvas.removeKeyListener(xyInterface);
        glcanvas.addKeyListener(xyInterface);
        .......
        .......

This object xyInterface is this class:


public class InterfaceXY implements GLEventListener, MouseListener, KeyListener
{
        .......
        .......
        public void keyPressed(KeyEvent e) { System.out.println("Pressed"); }
        
        public void keyReleased(KeyEvent e) {System.out.println("Released"); 
        
        public void keyTyped(KeyEvent e) { System.out.println("Typed"); }


This class also has the overwrites for MouseListener, but they work fine.

Can anyone hint to me what I am missing. Does it have something to do with the XYPlot class extending JInternalFrame. Do I have to set focus to use the KeyListener? Am I adding the listerner to the GLJPanel correctly? Please post questions if you need additional inofmration about what I’m trying to do.

I think you may need to request focus on the GLJPanel. Take a look at the call to requestFocus() in the source code for the JRefract demo.

Thanks Ken I found what I needed and it works. Your the best.