谁能帮我解决我的问题?我有一个组合框,其中项目来自我的数据库,并且会根据其他组合框而有所不同。这是我的代码
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();
}
我的问题是我希望 cmbBarangay 组合框变成 AutoComplete 组合框,如果我键入第一个字母,它会在里面建议这些单词和这些字母。还有一个自动完成组合框,它将接受不包含在项目列表中的单词。我尝试过搜索,但这对我不起作用,他们的示例主要是 itemlist ex。{苹果、香蕉、芒果}。我找不到处理来自数据库的项目列表的教程。谢谢您的帮助。