Activity 6.5 - Constructing a user interface to demonstrate fonts

Topic

In this activity we create a User Interface, using a variety of visual components.

Task

You are asked to develop a User Interface for a program that will demonstrate fonts. When the application runs, the window should look like this:

The figure displays a rectangle which has a large area to display text, and various buttons and labels to control the way the text is displayed.
The figure is described in detail in the main text where it decribes the interface, immediately below the figure.

The interface consists of:

With the exception of the labels, all these types of element were used in Activity 6.4.

The enclosing frame has title "Font demo" and dimensions 400 by 240. It uses a 2 by 1 grid layout.

In this activity we are only developing the interface and the program will not be capable of actually displaying the chosen font. We will continue this example in Unit 7.

Instructions

  1. Create a new project called MyEx6_5 in the Unit 6 folder. In the New Java Application wizard name the Main Class myex6_5.FontDemoTest.
  2. Add a new class FontDemo that implements the interface shown above. You are not expected to write a hierarchy of classes as was done in Exercise 6.4. Instead you should add all the interface elements in the same class.
  3. Complete the main class FontDemoTest to create an instance of FontDemo and display it. Compile and run your program.
  4. Our sample code appears in the Solution file.