I'm using a JComboBox
to search a query from a sql DB. I want to search query when a letter is typed. I'm using net beans IDE. Here is the automated code.
srch.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
srchKeyReleased(evt);
}
}
private void srchKeyReleased(java.awt.event.KeyEvent evt) {
//Searching code
}
But nothing happens. I'm sue that there is no error in searching code.
Please give me the code to do this without automated code from IDE.
name of JComboBox
is srch
. Combo box editable=true.
Thank you.
Since your combobox is editable, you should try this:
srch.getEditor().getEditorComponent().addKeyListener()
instead of this
srch.addKeyListener()