0
ボタン「Nochmal」(ドイツ語btw)を押したときにプログラムを繰り返したい すべて動作しますが、最初からプログラムを繰り返すコードはわかりません。 btw自身の入力を持つ乱数ジェネレータ。JOptionPane repeatボタンを押してプログラムを実行
package main;
import java.util.Random;
import javax.swing.*;
public class randomNumberGen {
public static void main(String[] args) {
Object[] options1 = { "Nochmal", "Quit" };
int eingabe = Integer.parseInt(JOptionPane.showInputDialog("Von 0 bis: ", null));
Random rn = new Random();
for(int i =0; i < 1; i++)
{
int answer =rn.nextInt(eingabe) + 1;
JPanel antwort = new JPanel();
antwort.add(new JLabel("Deine Zahl lautet: " + answer));
int result = JOptionPane.showOptionDialog(null, antwort, "RNG",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
null, options1, null);
if (result == JOptionPane.YES_OPTION){
//what to put into here?
}
}
}
}
for(int i = 0; i <1; i ++) 'はおそらく必要ありません。 – notyou