我对以下代码有疑问。我创建了一个骰子程序并创建了一些单选按钮。我希望单选按钮执行以下操作:选中后,我想掷骰子按钮的数字;问题是,一旦我点击它,它就会给我结果。我想选择它,然后单击滚动按钮,然后给我结果。
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);
}