Solved

jComboBox + Press Enter

Posted on 2003-11-11
13
609 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
  • 6
  • 6
13 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 71
@SBGen Method 3 38
stackato and cloud 4 74
fibonacci ten numbers 4 28
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now