How do I bind a function key say(F11 etc) to a JInternalFrame, so it can activate a particular action.
I tried with the following
this.getInputMap().put(KeyStroke.getKeyStroke("F11"), new AbstractAction() {
public void actionPerformed(ActionEvent e) {
System.out.println("Called");
}
});
but it never gets called? Or please suggest how to activate a button inside a JInternalFrame using function key.
Thanks Azlam
Well, focus is never on the internal frame itself, focus is on a component on the internal frame.
So you should probably be adding the binding by using
internalFrame.getRootPane()....
You may also need to use
"WHEN_ANCESTOR_OF_FOCUSED_COMPONENT"
input map.
The blog entry on Key Bindings explains this in more detail.