//
// PrintName.java
// This application displays a name in two different formats in a GUI
// window
//
// Dale, et al., page 381
// 

import java.awt.*;       // Supplies layout manager
import javax.swing.*;    // Supplies JFrame class for output display

public class PrintName
{
    public static void main(String[] args)
    {
	final String FIRST  = "Herman";       // Person's first name
	final String LAST   = "Herrmann";     // Person's last name
	final char   MIDDLE = 'G';            // Person's middle initial

	JFrame outputFrame;                   // Declare JFrame variable
	Container outputPane;                 // Declare Container variable

	String firstLast;                     // Name in first-last format
	String lastFirst;                     // Name in last-first format

	// Create a JFrame object
	outputFrame = new JFrame();

	// Ask the JFrame object to return a content pane Container object
	outputPane = outputFrame.getContentPane();

	// Specify the action to take when the window is closed
	outputFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	// Specify the size of the JFrame object
	outputFrame.setSize(300, 200);

	//Specify a layout manager for the content pane
	outputPane.setLayout(new FlowLayout());

	// Add output to the content pane
	//   1. Display name in first-last format
	firstLast = FIRST + " " + LAST;
	outputPane.add(new JLabel("Name in first-last format is "
				  + firstLast));

	//   2. Display name in last-first-middle format
	lastFirst = LAST + ", " + FIRST + ", ";
	outputPane.add(new JLabel("Name in last-first-initial format is "
				  + lastFirst + MIDDLE + "."));
	
	// Make the JFrame object visible on the sceen
	outputFrame.setVisible(true);
    }
}

