My values get it from database (mysql).
If in text field, there will be like this :
txtMID.setText("" + rs.getString("menu_id"));
Are in combo box like this?
cmbMCat.setSelectedItem("" + rs.getString("menu_cat"));
How about radio button? I think that use if-else condition. But I don't get how to write the code.
My radio button set in the end of coding : private String type;
and here the button :
private void rbMFoodActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
showCategory();
type = "Food";
}
private void rbMDrinkActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
showCategory();
type = "Drink";
And this my showCategory();
private void showCategory() {
try {
cmbMCat.removeAllItems();
Statement stmt;
stmt = con.createStatement();
if (rbMFood.isSelected()) {
ResultSet rs = stmt.executeQuery("SELECT * FROM menu_cat WHERE type_id = 'TY02'");
while (rs.next()) {
cmbMCat.addItem(rs.getString("menu_cat"));
}
} else {
ResultSet rs = stmt.executeQuery("SELECT * FROM menu_cat WHERE type_id = 'TY01'");
while (rs.next()) {
cmbMCat.addItem(rs.getString("menu_cat"));
}
}
} catch (Exception e) {
}
Please, I really need your help T__T Ask if my question make you confused because my bad english.