changing a JComboBox's list according to the field
posted 12 years ago
I'm trying to have a user type in a name in the JComboBox's text field. As each letter of the name is typed the List will change with the results of a query to a mysql database.
For example: I type "J" The list would contain results from a database query of names begining w/ J ie. "Jason" "James" "John"
Another example: If I continue to type "Ja" The list would change again to something like "Jason" "James"
Can anyone help?
i'm using a document listener on the JCombox's text field but the JComboBox always trys to change the input field an I get errors like:
java.lang.IllegalStateException: Attempt to mutate in notification at javax.swing.text.AbstractDocument.writeLock(Unknown Source at javax.swing.text.AbstractDocument.replace(Unknown Source) at javax.swing.text.JTextComponent.setText(Unknown Source)