I have a JComboBox on my applet which has all languages spoken in the world. If the user is trying to get to SPANISH and types S to get to the languages beginning with S, the combo box is firing itemStateChanged on this combo box and processing for the selection SAMOAN (the first S language). However, I only want itemStateChanged to fire when the user has made his final selection, in this case SPANISH. What do I do so that itemStateChanged is only fired when the user has finished selecting the language? I tried putting code in itemStateChanged checking if the popup is not visible then update the language field, but that doesn't ever seem to fire.
Thanks in advance!
verduka fox
Ranch Hand
Joined: Jan 18, 2001
Posts: 178
posted
0
Does anyone know the answer to this? I'm really stumped and need to solve this ASAP. Thanks!
verduka fox
Ranch Hand
Joined: Jan 18, 2001
Posts: 178
posted
0
I still need an answer to this problem. Can anyone please help me? Thanks in advance. . .
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Since the problem is that this is getting fired at times you don't want it fired, Perhaps if you showed us the code that calls this method we might have a chance of figuring it out.
"JavaRanch, where the deer and the Certified play" - David O'Meara
verduka fox
Ranch Hand
Joined: Jan 18, 2001
Posts: 178
posted
0
Here is the code:
Again, what's happening is that the event is fired when the user types a letter to get to that section, such as typing 'S' to get to the languages beginning with S. The first S language (SAMOAN) is selected, which executes itemStateChanged and thus executing the updateLanguage() method. What I need is some way to execute updateLanguage() only when the user has made his final selection. This means that if the user types S to get to the S languages and means to select SPANISH, only fire updateLanguage() when the user has made his final selection. Is this possible? If so, how? Thanks again.
Tim Kemper
Greenhorn
Joined: Jan 05, 1999
Posts: 4
posted
0
I believe the issue is how you want to designate that the user has made his final decision. You could decide that the selection was finished when the focus was moved from the combo box. In this case, add a FocusListener to the combo box and get the selection in the focusLost method.
Tyler Bye
Greenhorn
Joined: Aug 15, 2001
Posts: 1
posted
0
That brings up another problem. I don't believe JComboBox fires FocusEvent(s).