Binding of the 'ENTER' and 'ESCAPE' buttons
Hi everyone,
Do you know how to bind the "ENTER" and the "ESCAPE" buttons to specific buttons in our
application. Let say, I have a "SKIP" button on one panel and I want to bind the "ESCAPE" button
to that "SKIP" button, how can I do that?
Thanks,
Naron
Re: Binding of the 'ENTER' and 'ESCAPE' buttons
Hi Naron,
U can bind keys such as 'enter' etc, using the java.awt.event.KeyEvent class. Use the keycode constants such as KeyEvent.VK_ENTER which corresponds to the 'enter' key.
The Java API provides a whole list of keycodes corresponding to the ASCII values. Hope this helps..
Regards,
Sushma
Re: Binding of the 'ENTER' and 'ESCAPE' buttons
Hi Sushma,
I tried to use the function "addKeyListener()" because my class is a subclass of JPanel. However,
it doesn't work. It seems the JPanel doesn't have the focus. I tried the same function on a textfield
and it works fine , no problem. Do you know how to use the "addKeyListerner()" on a JPanel or its
subclasss.
Thanks,
Naron