Keypress listener anywhere in a JFrame

Hello!I want to listen for a keypress (F12) from anywhere in my JFrame window, exactly like if I added a menubar with an accelerator.I can't just register a KeyListener on the JFrame because I have serveral panels on it.Any ideas?//John
[272 byte] By [mrlogitecha] at [2007-11-27 8:07:14]
# 1
Read the tutorial How to Use Key Bindings http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html
Rodney_McKaya at 2007-7-12 19:49:55 > top of Java-index,Desktop,Core GUI APIs...
# 2

Thanks! works great now, here is the code if anybody is intrerested:

private void addKeyBindings() {

Action finishAction = new AbstractAction() {

private static final long serialVersionUID = 1;

public void actionPerformed(ActionEvent e) {

onButtonFinishClick( e ); //Forward

}

};

//Set input actions

InputMap im = _bFinish.getInputMap( WHEN_IN_FOCUSED_WINDOW );

ActionMap am = _bFinish.getActionMap();

KeyStroke ks = KeyStroke.getKeyStroke( "F12" );

im.put( ks, "onf12" );

am.put( "onf12", finishAction );

}

mrlogitecha at 2007-7-12 19:49:55 > top of Java-index,Desktop,Core GUI APIs...