Can anyone help me with my problem? I have a combo box where the item is from my database and will vary according to other combo box. here's my code for that
if (City.equals("Taguig")){
ArrayList<String> Taguig = new ArrayList<String>();
String sql = "SELECT * FROM Barangay";
try {
this.stm = this.con.createStatement();
this.rs = this.stm.executeQuery(sql);
while (rs.next()) {
String BrTaguig = rs.getString("Taguig");
Taguig.add(BrTaguig);
}
DefaultComboBoxModel model = new DefaultComboBoxModel(Taguig.toArray());
this.cmbBarangay.setModel(model);
} catch (SQLException ex) {
ex.printStackTrace();
}
My problem is I want that cmbBarangay Combo box will turn into AutoComplete combo box that if I type the first letter, it will suggest those words inside with that letters. and also an autocomplete combo box that will accept words that does not included in the itemlist. I've tried searching but that doesn't work for me and their example is mostly given itemlist ex. {apple,banana,mango}. I cant find a tutorial that deals with the itemlist comes from the database. Thank you for your help.