CSCI 161: Introduction to Programming I
Spring 2007
Lab 3: Monogram (Using Classes)

Due Thursday, February 15th at the beginning of class

 

Overview

Prompt the user for her full name (e.g., Jane Marie Doe). Store the first, middle, and last names in a single String.  Do the processing required to get the three initials (see hints below).  Now create a JFrame with 3 nested JPanel's, with the first panel displaying the user's first initial, the second panel displaying the user's middle initial, and the third panel displaying the user's last initial, thus monogramming the user's name (JMD in this case).

 

Input Specification

Prompt the user for a single String that will hold the first, middle, and last name. Do this graphically with a JOptionPane.

 

Output Specification

In a JFrame consisting of three panels, output the user's initials. Each panel should consist of a JLabel containing a single character. Use a statement like


label.setFont (new Font ("Helvetica", Font.BOLD, 72));

to select a large font size for each initial. You may experiment with fonts and background and foreground colors.

 

Hints

You can use a Scanner object to break the full name into its three component strings.  When you create the Scanner, instead of referencing System.in, reference the String object holding the full name.

 

You will find the substring method of String (p. 119) helpful.

 

Listing 3.8 in the text (p. 145) will prove useful for the nested panels.