some component eat my F8 key
Hello,
I've got the problem with some component in my app.
In menu bar I've got accelerators for F5, F6, F7, F8. what is funny F5 and F7 works, but F6 and F8 are eaten by some component.
I've seen similar problems on Forum (with i.e. Ctrl-C issue)
One solution is to clear ActionMap for components and their parents, but i've got nothing from getActionMap() (i mean no bindings) for component (JSplitPane) which for 100% do something on F8 pressed.
Second fix is to make global handlind, but i'd avoidit.
How to find that component? What so spcial with F8 or F6/
thanks
Seb
[634 byte] By [
qeba] at [2007-10-1 23:27:16]

:) yes
thay work even in that aplication - i explain it more with more details
My app got menu bar, and two JPanel. In first (main) there ara lots of other components including JSplitPanes. Second one got only label and textbox.
If put focus in textbox in second panel, all accelerators (including F6 and F8) work, but if I put foucs some component of first panel F6 and F8 don't work. Odd isn't it?
Meanwhile, I've tried a trick with ActionMap and InputMap, but as I suspect it fails.
I'm using 1.4.2 if it matters.
regards
qeba at 2007-7-15 14:09:41 >

Also try:
AWTEvent.MOUSE_EVENT_MASK);
toolkit.addAWTEventListener(FunctionKeyListener, AWTEvent.KEY_EVENT_MASK);
FunctionKeyListener= new AWTEventListener() {
public void eventDispatched(AWTEvent event) {
// Only for key events
if (event.getID() == KeyEvent.KEY_PRESSED) {
KeyEvent ke = (KeyEvent)event;
if (ke.getKeyCode() == KeyEvent.VF_F8) {
ke.consume();
// do something
}
}
}
};
It works for me.
I've just stumbled across this problem. A better solution is:
InputMap im = mySplitPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent();
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), null);
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), null);
The trick is the getParent() of the InputMap, but it might vary depending on the UI.
Another solution that should work more directly, but will erase all key bindings for the component is to:
SwingUtilities.replaceUIInputMap(mySplitPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);