From b6400bb145e46c7ea809f3e74bd695aa6684bba7 Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Tue, 12 Feb 2019 12:29:29 -0500 Subject: [PATCH] Added a program that generates popup boxes --- PopUp.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 PopUp.java diff --git a/PopUp.java b/PopUp.java new file mode 100644 index 0000000..a43eab5 --- /dev/null +++ b/PopUp.java @@ -0,0 +1,26 @@ +//Java/JavaTutorials/PopUp.java +//Matthew Ellison +// Created: 02-12-19 +//Modified: 02-12-19 +//This is a simple tutorial on pop up boxes + + +import javax.swing.JOptionPane; + +public class PopUp{ + public static void main(String[] argv){ + //Prompt the user to enter a string + String words = JOptionPane.showInputDialog("Enter a string to be printed"); + JOptionPane.showMessageDialog(null, words); + //Prompt the user to enter 2 numbers and print their sum + words = JOptionPane.showInputDialog("Enter a number to be summed"); + int num1 = Integer.parseInt(words); + words = JOptionPane.showInputDialog("Enter another number to be summed"); + int num2 = Integer.parseInt(words); + JOptionPane.showMessageDialog(null, num1 + " + " + num2 + " = " + (num1 + num2)); + } +} + +/* Results: + +*/