I have a problem with the following code. I created a dice program and I created some radio buttons. I want the radio buttons to do the following: When selected, I want to roll the dice the number that the button has; the problem is that once I click on it, it gives me the results. I want to select it and then click the roll button then give me the results.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Random dice = new Random ();
int number;
for (int counter=1; counter<=5;counter++) {
number= 1+dice.nextInt(6);
JOptionPane.showMessageDialog(null, number);
}
}
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Random dice = new Random ();
int number = 0;
for (int counter=1; counter<=5;counter++)
number= 4+dice.nextInt(4);
JOptionPane.showMessageDialog(null, number);
}