简体   繁体   中英

How do I use JOptionPane in a while loop?

The code segment below is a part of a bigger program, but I think this is where I'm having the issue. So, I am trying to use a while loop to ask for input over and over until the program is done, and the dialog box is not coming up and I don't know why. I would really appreciate it if someone could take a look and tell me what I'm doing wrong. If you want to see the entire program just tell me.

Code

        boolean done = true;

        while(!done)
        {
            Grid grid = new Grid();
            boolean userDone = true;
            int compRandom = (int) (Math.random() * 9) + 1;

            String input1 = JOptionPane.showInputDialog("Please input a number 1-9 for where you would like to place your piece: ");
                Integer input = Integer.parseInt(input1);
    boolean done = true;

一定是

    boolean done = false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM