2017-10-03 7 views
0

버튼 "Nochmal"(독일어 btw)을 누르면 프로그램을 반복하고 싶습니다 모든 것이 작동하지만 처음부터 programm를 반복하는 코드는 알지 못합니다. 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); 

당신은 비록 주요 방법에서 당신의 논리를 얻어야한다.

관련 문제