2017-10-03 7 views
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? 
      } 
     } 

    } 
} 
+0

for(int i = 0; i <1; i ++) 'はおそらく必要ありません。 – notyou

答えて

0

ちょうど置く:

main(args); 

をあなたがが主な方法のうち、あなたのロジックを取得する必要があります。

関連する問題