Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

changing a JComboBox's list according to the field  RSS feed

Jason Ti
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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)

any ideas?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!