?
Solved

jComboBox + Press Enter

Posted on 2003-11-11
13
Medium Priority
?
622 Views
Last Modified: 2006-11-17
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 ?
0
Comment
Question by:mikekwok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 9720786
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
 

Author Comment

by:mikekwok
ID: 9720849
how can i check if the keyevent e is "vk_enter" in the actionperformed ?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9720971
That's the only key event the actionPerformed will recognise anyway, so you don't need to check.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mikekwok
ID: 9720986
it is actionevent pass into the void but not keyevent, how can i check the keystroke is enter?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9721003
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
 

Author Comment

by:mikekwok
ID: 9864983
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
 

Author Comment

by:mikekwok
ID: 9864996
Do i need to use processKeyEvent to handle my situation ?
0
 

Author Comment

by:mikekwok
ID: 9894880
How can i distinguish between the ENTER key and other key which is pressed when jcombobox in focus ?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9895715
PLease specify your *exact* requirements and i'll try to help
0
 

Author Comment

by:mikekwok
ID: 9901056
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 10049962
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 10051679
I'm happy to look into this further if the questioner's still interested
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11141484
8-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question