簡體   English   中英

如何在while循環中使用JOptionPane?

[英]How do I use JOptionPane in a while loop?

下面的代碼段是更大程序的一部分,但是我認為這是我遇到的問題。 因此,我試圖使用while循環反復詢問輸入,直到程序完成,並且對話框沒有顯示出來,我也不知道為什么。 如果有人可以看看並告訴我我做錯了什么,我將不勝感激。 如果您想查看整個程序,請告訴我。

        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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM