File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JComboBox issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox issue" Watch "JComboBox issue" New topic
Author

JComboBox issue

verduka fox
Ranch Hand

Joined: Jan 18, 2001
Posts: 178
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
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
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
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
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
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
That brings up another problem. I don't believe JComboBox fires FocusEvent(s).
Takeshi Toyohara
Greenhorn

Joined: Feb 03, 2002
Posts: 21
check out
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=000683
two possible solutions there i think
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JComboBox issue