I'm doing a project (something like a restaurant) for collage, and I'm not very good in Java (they didn't really try to teach us). The principle of the project is to show a message saying what radio buttons and check boxes I've selected.
I have 5 radio buttons, they are for selecting a meal, and 5 check boxes for selecting a side dish. I've managed to have the radio buttons work but I don't know how to make the check boxes work...
This is the code for the radio buttons (this goes for all 5):
private void jRadioButton1ItemStateChanged(java.awt.event.ItemEvent evt) {
if (evt.getSource().equals(jRadioButton1))
{
Meal= jRadioButton1.getText(); //Meal is a String
}
I tried the same code for the check boxes but it only shows one side dish in the message, even though I selected multiple...
The code for the button that shows the message:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(rootPane, "You have chosen:\n" + String.valueOf(Meal) + "\n" + String.valueOf(SideDish));
}
So basically, if anyone is willing to help, please tell me how to make the check boxes work... that every selected check box is shown in the message, like this:
You have chosen: Pizza //meal Ketchup //selected side dish #1 Chilli peppers //selected side dish #2 Feta cheese //selected side dish #3
I hope my question is clear...