Using JComboBox as a search box

前端 未结 3 1794
一生所求
一生所求 2020-12-22 11:47

Im using a JComboBox to search a query from a sql database. Here is my code.

private void srKeyTyped(java.awt.event.KeyEvent evt){
    sr.remove         


        
3条回答
  •  误落风尘
    2020-12-22 11:53

    Use an ActionListener instead of the looking for the key press. When a combobox's selection is edited it will fire an ActionEvent when the editing is done.

    When you get this part working, you should move this logic off to another thread and populate the combobox's items when it returns. Otherwise your UI will hang while the SQL query occurs.

提交回复
热议问题