import java.awt.*; import javax.swing.*; /** a little application that simply throws up a couple of example JOptionPanes @author Sharon Tuttle @version 2021-09-22 */ public class SimpleOptionPaneTest { /** throws up a couple of example JOptionPanes @param args not used here */ public static void main(String[] args) { // create and show using JOptionPane to create // and show a message dialog box (just displays // a message, does not return anything when that dialog // is closed) JOptionPane simpleDialog = new JOptionPane(); simpleDialog.showMessageDialog(null, "Welcome to \nCS 235"); // here we are using JOptionPane static method showInputDialog // to display an input dialog box, which returns a String // entered by the user into its text field if user // clicks OK, and returns null if user clicks cancel! String input = JOptionPane.showInputDialog( "(check out the difference when you click OK vs. Cancel)\n\n" + "Please enter a color: "); System.out.println("You entered: <" + input + ">"); } }