// JOptionPane for inputing data import java.awt.*; import javax.swing.*; class MyGUI3 { public static void main (String[] args) { JFrame mywindow = new JFrame (); mywindow.setSize (400, 400); mywindow.setTitle ("GUI13 Example"); mywindow.setVisible(true); // To exit from the program by pressing the X button, // the following statement must be included mywindow.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // Reading data with JOptionPane class String a; a = JOptionPane.showInputDialog (mywindow, "Enter first number to add:"); String b; b = JOptionPane.showInputDialog (mywindow, "Enter second number to add:"); int a1, b1, result; a1 = Integer.parseInt(a); b1 = Integer.parseInt(b); result = a1 + b1; JOptionPane.showMessageDialog (mywindow, a1 + " + " + b1 + " = " + result); } }