Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JComboBox issue

 
verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know the answer to this? I'm really stumped and need to solve this ASAP.
Thanks!
 
verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still need an answer to this problem. Can anyone please help me? Thanks in advance. . .
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That brings up another problem. I don't believe JComboBox fires FocusEvent(s).
 
Takeshi Toyohara
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check out
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=000683
two possible solutions there i think
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic