Hi, I need to set hot keys / shortcut keys /mnemonics whatever u call...to the objects of class Button. I found an option to set Mnemonics to an instance of JButton but plz let me know a way to create shrt keys to a plain java.awt.Button class without using any event handling mechanisms or so .. Tell me is it possible first of all without using any event handling mechanisms?
hi raj thank you for your response...can u plz detail of how to handle the shortcut keys after adding this listener. hope I am nt bugging fr a minute thing!! very new to awt
create the myKeyListener class and implement KeyListener interface then override the following interface methods.
public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub System.out.println("keyPPressed"); //Get the key code and process what key you want. }
public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub }
public void keyTyped(KeyEvent e) { // TODO Auto-generated method stub }
Note: It works only when it focused on the particular button or key listener component.