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 ?
mikekwokAsked:
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.

CEHJCommented:
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?
0

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 ?
0
CEHJCommented:
That's the only key event the actionPerformed will recognise anyway, so you don't need to check.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

mikekwokAuthor Commented:
it is actionevent pass into the void but not keyevent, how can i check the keystroke is enter?
0
CEHJCommented:
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.
0
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 ?
0
mikekwokAuthor Commented:
Do i need to use processKeyEvent to handle my situation ?
0
mikekwokAuthor Commented:
How can i distinguish between the ENTER key and other key which is pressed when jcombobox in focus ?
0
CEHJCommented:
PLease specify your *exact* requirements and i'll try to help
0
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.
0
sudhakar_koundinyaCommented:
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.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
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.
0
CEHJCommented:
I'm happy to look into this further if the questioner's still interested
0
CEHJCommented:
8-)
0
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
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.