Source of JOptionPaneDemo.java


  1: 
  2: 
  3: import javax.swing.JOptionPane;
  4: 
  5: public class JOptionPaneDemo
  6: {
  7:    public static void main(String[] args)
  8:    {
  9:       String appleString =
 10:          JOptionPane.showInputDialog("Enter number of apples:");
 11:       int appleCount = Integer.parseInt(appleString);
 12:           
 13:       String orangeString =
 14:          JOptionPane.showInputDialog("Enter number of oranges:");
 15:       int orangeCount = Integer.parseInt(orangeString);
 16:           
 17:       int totalFruitCount = appleCount + orangeCount;
 18:       JOptionPane.showMessageDialog(null, 
 19:              "The total number of fruits = " + totalFruitCount);
 20:       System.exit(0);
 21:    }
 22: }