posted 23 years ago
Hello,
Does anyone of you ever tried to replace the default behaviour of some "special" key bindings like: TAB, BACK_SPACE, SPACE, DELETE, ... from a JTextField?
I�m using jdk1.3 and I�m trying, like I've said, to create a custom JTextField which will have my special actions or responses for those KeyStrokes.
I thought it might be easy because you got the InputMap/ActionMap bindings. So, I create my custom bindings in the InputMap/ActionMap overriding the mentioned KeyStrokes. I checked that the only InputMap with actions in it was WHEN_FOCUSED so I worked with it. Surprisingly, it didn't work. I tried to override the key bindings of the associated Keymap but, since 1.3 wrapped Keymap with InputMap/ActionMap, the result was as meaningless as before.
Then, I tried with a KeyListener. My key listener couldn't be able to catch the TAB. The rest of KeyStrokes were caught but the default action kept showing, even if I explicitly consume the KeyEvent.
Also, I tried overriding the processKeyEvent method. Once again the default action was there.
I kept reading and I found the Swing's Input Method Framework and I got three times the confusion I had in the first place.
Could anyone give me a hint on this?
Thank you
Luis Alfredo