//MessageDialogDemo.java //demo of output with JOptionPane windows. //similar to System.out.println and g.drawString import javax.swing.*; //needed for JOptionPane public class MessageDialogDemo { public static void main (String [] args) { String name; int age; double radius, circumference, area; String firstName, lastName; firstName = "Fred"; lastName = "Smith"; name = firstName + " " + lastName; //JOptionPane output dialog windows. //showMessageDialog displays a string JOptionPane.showMessageDialog( null, "Welcome: " + name ); //null must be the first argument. //2nd argument is string, here concatenation. age = 23; JOptionPane.showMessageDialog( null, "You are " + age + " years old"); radius = 12.5; circumference = 2 * Math.PI * radius; area = Math.PI * radius*radius; JOptionPane.showMessageDialog( null, "Circumference=" + circumference + "\nArea=" + area); } }