Question

I can catch event in a custom component using processKeyEvent method like this way.

class CustomComp extends JPanel
{
   @Override
   public void processKeyEvent(final KeyEvent event)
    {
     if (event.getKeyCode() == KeyEvent.VK_DOWN)
      {
          //do somthing here
      }
   }
}

is there any alternative ways to do that?

Was it helpful?

Solution

The preferred method would probably be to use the Key Bindings API

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top