Possible Duplicate:
Dynamic JComboBoxes
I am a newbie in java program. I have this problem with my program about comboboxes. I have 3 combobox (cbxType, cbxItem, and cbxColor). I want that the item list in the second combobox (cbxItem) is changed based on the first one (type), and then the third combobox's(cbxColor) item list changed based on the selected item in the second one (cbxItem). i've been trying to solve this problem by my own code, the second combobox work fine when the first one changed, but then the third combobox won't show any item after i change. here is my code. thanks for your help guys and sorry for my bad english..
private void viewCbxType(){
String sql;
try {
sql ="Select distinct productItem from Product ";
if(cbxType.getSelectedItem() != "<<Product Type>>"){
String prType = cbxType.getSelectedItem().toString();
sql ="Select distinct productItem from Product WHERE productType='" +prType+"'";
cbxItem.removeAllItem();
cbxItem.setSelectedIndex(0);
}
}
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs =st.executeQuery();
while (rs.next()) {
String prItem = rs.getString("productItem");
cbxItem.addItem(prItem);
}
}catch (SQLException se) {}
}
I call that method at actionPerformed for my first combobox and make similiar to the second