title: Java Swing: Get text value from JOptionPane
body: <p>I'd like to create a new window which is used in POS system. The user input is for an amount of money the customer has and the window has to display the exchange amount. I'm new with <code>JOptionPane</code> feature (I have been using <code>JAVAFX</code> and it's different).</p>
  
  <p>This is my code:</p>
  
  <pre><code>public static void main(String[] argv) throws Exception {
      String newline = System.getProperty("line.separator");
      int cost = 100;
      int amount = Integer.parseInt(JOptionPane.getText()) // this is wrong! This needs to come     from user input box in the same window.
      JFrame frame = new JFrame();
      String message = "Enter the amount of money"+newline+"The exchange money is: "+amount-cost;
      String text = JOptionPane.showInputDialog(frame, message);
      if (text == null) {
        // User clicked cancel
  }
  </code></pre>
  
  <p>Is there any suggestion?</p>