From: Michael B. <mic...@gm...> - 2011-10-26 22:59:44
|
Hello LuVar, > consuming -> (eating) key events is mean to listen for key event and not send consumed > key event to parent component. Thus parent component does not receive any key events. I think the difference in behaviour is because in version 2.7 JMapPane is not a focussable component (ie. it has the default JPanel state) while in version 8.0 it is focussable (set in the AbstractMapPane constructor). > I had to move my key listener from form to jmappane. Right - but why is that a problem ? > I have taken a look at that code ant it seems that if someone attaches key listener > to some Component (www.java2s.com/Open-Source/Java-Document/6.0-JDK- > Core/AWT/java/awt/Component.java.htm search for "newEventsOnly" and read javadoc), > it will not send key events to parent component... Strange for me. Yes, these aspects of Swing are confusing and poorly documented (as you can tell by the questions in StackOverflow and other forums). > Probably coding something like "getParent().sendKeyEvent..." in key handler (or > abstract map pane) class could avoid of key events consuming. I think I'd prefer to change over to using Swing key bindings instead as mentioned in my previous reply because then the component hierarchy is dealt with explicitly. What do you think ? Michael |