Answer:

See below.

Runnable Program

The field is 15 characters long, which means that 15 characters will be displayed. The object can hold more than 15, but the user will have to use the arrow keys on the keyboard to scroll through them.

import java.awt.*; 
import java.awt.event.*;
import javax.swing.*;

public class TextEg1 extends JFrame
{

  JTextField text;

  public TextEg1()
  {  
     text = new JTextField( 15 );
     getContentPane().setLayout( new FlowLayout() );
     getContentPane().add( text );
     setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );   
  }

  public static void main ( String[] args )
  {
    TextEg1 teg  = new TextEg1() ;

    teg.setSize   ( 300, 100 );     
    teg.setVisible( true );      
  }
}

This program can be copied to an editor, saved to a file, compiled, and run.

QUESTION 5:

It would be nice if the frame had some words next to the text field that described its purpose. What do you suppose the Swing class for labels is called?