jComboBox + Press Enter

I have an jCombobox and I want to do something if the jcombobox is in focus and the user press Enter. I have already implemented ActionPerformed listener for the jComboBox. When I add KeyListener to that JCombobox, I found that the jcombobox run the actionperform listner instead of the key event listener. would somebody tell me how to solve this problem ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Out of interest, why are you interested in the KeyListener, if it's the enter key you're interested in? What's wrong with actionPerformed?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mikekwokAuthor Commented:
how can i check if the keyevent e is "vk_enter" in the actionperformed ?
That's the only key event the actionPerformed will recognise anyway, so you don't need to check.
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

mikekwokAuthor Commented:
it is actionevent pass into the void but not keyevent, how can i check the keystroke is enter?
The only key stroke that will be recognised is the enter key. If getSource() returns the combo box, then the enter key was pressed. AFAIK the combo box doesn't generate ActionEvents otherwise.
mikekwokAuthor Commented:
I found that the only key stroke that will be recongised is not only the enter key. It also recongnises the up arrow and down arrow. WOuld somebody pls help me ?
mikekwokAuthor Commented:
Do i need to use processKeyEvent to handle my situation ?
mikekwokAuthor Commented:
How can i distinguish between the ENTER key and other key which is pressed when jcombobox in focus ?
PLease specify your *exact* requirements and i'll try to help
mikekwokAuthor Commented:
I have a jcombobox, i have implemented actionperformed, it will do  string manipution when the jcombobox changed. i also want it to do another thing when jcombobox is in focus and user press ENTER. the problem is that the actionperformed recognize BOTH the jcombobox changed and ENTER is pressed. Do I explain my problem more clear ? Look for your reply. Thanks.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

[deleted and points refunded]

Please leave any comments here within the next seven days.
EE Cleanup Volunteer
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
I'm happy to look into this further if the questioner's still interested
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.