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.
Hi First of all your question is not clear. The below suggestions are of based on my understanding of your question.
On loading of your application you want to initializing you UI components based on the data coming form database(mysql).
So you will get one field like true or false about that radio button from database
if(true)
rbmFood.setSelected(true);
else
rbmDrink.setSelected(true);