//
// PrintName.java
// This program displays a date in four different formats by 
// building strings up from the component parts of the date
// using string concatenation expressions
// Uses a grid layout to position the date labels in the GUI window
//
// Dale, et al., page 383
// 

import javax.swing.*;                    // For JFrame, JLabel classes
import java.awt.*;                       // For layout manager

public class DateFormats
{
    public static void main(String[] args)
    {
	JFrame outDisplay;                   //Declare a frame variable
	Container outPane;                   //Container for content pane

	final String MONTH_NAME = "August";  //The name of the month
	final String MONTH_NUMBER = "8";     //The number of the month
	final String DAY = "18";             //The day of the month
	final String YEAR = "2001";          //The four-digit year number
	
	String first;                        //Date in Month day, year format
	String second;                       //Date in day Month year format
	String third;                        //Date in mm/dd/yyyy format
	String fourth;                       //Date in dd/mm/yyyy format
	
	//Create formats from date components
	first = MONTH_NAME + " " + DAY + ", " + YEAR; 
	second = DAY + "  " + MONTH_NAME + " " + YEAR;
	third = MONTH_NUMBER + "/" + DAY + "/" + YEAR;  
	fourth = DAY + "/" + MONTH_NUMBER + "/" + YEAR; 

	//Instantiate outDisplay
	outDisplay = new JFrame();
	outPane = outDisplay.getContentPane();
	outDisplay.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	outDisplay.setSize(300, 200);

	//Set the layout manager for outPane to be GridLayout
	outPane.setLayout(new GridLayout(5, 2));

	//Put display objects into the content pane
	outPane.add(new JLabel("Format"));
	outPane.add(new JLabel("Example"));
	outPane.add(new JLabel("Month day, year"));
	outPane.add(new JLabel(first));
	outPane.add(new JLabel("day Month year"));
	outPane.add(new JLabel (second));
	outPane.add(new JLabel("mm/dd/yyyy"));
	outPane.add(new JLabel(third));
	outPane.add(new JLabel("dd/mm/yyyy"));
	outPane.add(new JLabel(fourth));

	//Make the JFrame object visible on the screen
	outDisplay.setVisible(true);
    }
}
