title: When using JOptionPane.showInputDialog the window disappears before I can input and it's breaking parseint()
body: <p>Why do my JOptionPane.showInputDialog windows disappear before I can enter an input? I think it's what's causing my code to break. I've googled everything I can think of and nothing seems to apply to what I'm doing here. The error I get is:</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.NumberFormatException: For input string: &quot;&quot;
          at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
          at java.base/java.lang.Integer.parseInt(Integer.java:678)
          at java.base/java.lang.Integer.parseInt(Integer.java:786)
          at ChiliToGo.collectOrder(ChiliToGo.java:25)
          at ChiliToGo.main(ChiliToGo.java:13)
  </code></pre>
  <p>I'm just in a beginner java course so It's probably really dumb what I'm doing.</p>
  <p>I've tried formatting the string and moving the main method into a separate class to access the methods in a non-static way because they are the best solutions I got from the posts I found. I'm just really confused because the parseint shouldn't get the string until I press ok right? It's only there for a moment and I don't have a chance to enter the input</p>
  <p>Any help would be appreciated, code is below. Sorry if I made any mistakes this is my first post</p>
  <pre><code>import javax.swing.JOptionPane;
  
  public class ChiliToGo {    
      static int adultMeal = 7;
      static int kidsMeal = 4;
      static String adultMealOrder;
      static String kidsMealOrder;
      static int adultMealOrdered;
      static int kidsMealOrdered;
      static int totalPrice;
  
      public static void main(String[] args) {
          collectOrder();
          finalizeOrder();
      }
  
      public static void collectOrder() {
  
          adultMealOrder = JOptionPane.showInputDialog(&quot;Please enter the number of adult meals:&quot;);
          kidsMealOrder = JOptionPane.showInputDialog(&quot;Please enter the number of kids meals:&quot;);
          
          adultMealOrdered = Integer.parseInt(adultMealOrder);
          kidsMealOrdered = Integer.parseInt(kidsMealOrder);
      }
  
      public static void finalizeOrder() {
          for(int i = 0; i &lt; adultMealOrdered; i++) {
              totalPrice = totalPrice + adultMeal;
          }
          for(int n = 0; n &lt; kidsMealOrdered; n++) {
              totalPrice = totalPrice + kidsMeal;
          }
  
          JOptionPane.showInternalMessageDialog( null, &quot;Your order total is: &quot; + totalPrice, null, JOptionPane.INFORMATION_MESSAGE);
      }
  }
  
  </code></pre>