Sharad Golu wrote:Hi,
I am working on Swing application and not able to add keyListener on my JLabel component.
But mouseListener is working properly.
I need to add 3 keyboard events
1) Enter - To get inside label folder
2) Ctrl – need to perform ctrl+click operation.
3) Tab – to navigate from one Label to another.(and after browsing to the selected label user can press enter key)
I don't understand where the KeyListener comes into your design. You certainly don't need to listen for Tab keys, that's the job of the FocusListener for whatever component contains your JLabel. Likewise if the JLabel has focus, then pressing Enter will automatically do the same as if you clicked on the JLabel.
And I believe you would look for Ctrl-click in a MouseListener rather than a KeyListener.
I didn't look at any of your code because I don't think any of it was relevant (because of what I just posted above). But even if some of it was relevant, there was way too much of it. A small program with one or two labels would have sufficed. Anything else would just distract from the actual question.