Source of JOptionPaneDemo.java


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