Answer:

The Java documentation from Sun Microsystems is the best place.

Application with a Text Field

GUI of the application

You may have this documentation on your computer already. If not, you can download it from Sun. Scan it to see how these notes relate to the official documentation. The purpose of these notes is to overview the Swing package. Look to the documentation for complete coverage.

Here is one (of several) constructors for JTextField. The parameter says how many characters wide the field is.

JTextField( int numChars ) 

This program displays the frame at right.

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

public class TextEg1 extends 
{

   text;

  // constructor for TextEg1
  public TextEg1()
  {  
    text = new  ;
    getContentPane().setLayout( new FlowLayout() );
    getContentPane().add( text );
    setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );   
  }

  public static void main ( String[] args )
  {
    . . . . .
  }

}

QUESTION 4:

Fill in the blanks so that the field is 15 characters wide.