Question: Hello, Can you please make the cancel button in this program clear the user's input? import javax.swing.JOptionPane; /** * * @author user */ public class
Hello,
Can you please make the cancel button in this program clear the user's input?
import javax.swing.JOptionPane;
/** * * @author user */ public class AddIntegers { public AddIntegers() { String userInput = "yes"; while (userInput.equalsIgnoreCase("yes")) { try { String userInput1 = JOptionPane.showInputDialog ("Please enter an integer. "); String userInput2 = JOptionPane.showInputDialog ("Please enter another integer. "); int userInt1 = Integer.parseInt(userInput1); int userInt2 = Integer.parseInt(userInput2); System.out.println(); userInput = JOptionPane.showInputDialog ("The sum of the two numbers you entered in is: " + (userInt1 + userInt2) + " The product of the two numbers you entered in is: " + (userInt1 * userInt2) + " If you want to add and multiply two new integers," + " press yes (case does not matter). If not," + " press anything else. "); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Please enter int numbers " + "only."); } } } }
Thank you
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
