A good answer might be:

See below.

Runnable GUI

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.*;

public class TextEg1 extends Frame
{

  TextField text = new TextField( 15 );

  TextEg1()                               // constructor
  {  
     setLayout( new FlowLayout() );       // choose the layout manager 
     add( text )
  }

  public static void main ( String[] args )
  {
    TextEg1 teg  = new TextEg1() ;
    
    WindowQuitter wquit = new WindowQuitter(); 
    teg.addWindowListener( wquit );
    
    teg.setSize   ( 200, 150 );     
    teg.setVisible( true );      
  }
}

class  WindowQuitter  extends WindowAdapter 
{
  public void windowClosing( WindowEvent e )
  {
    System.exit( 0 );
  }
}

This program can be copied to NotePad, compiled, and run.

QUESTION 4:

It would be nice if the TextField had some words beside it that described its contents. What do you suppose the AWT class that puts labels in a frame is called?

Click Here after you have answered the question