A good answer might be:

  • How many AWT objects does the frame contain?
    • Four:
      • The Label "Enter Your Name:"
      • The TextField that follows it
      • The Label "Here is Your Name:"
      • The TextField that follows it.
  • Which of them need a registered listener?
    • Only the TextField that the user types into.

Repeater

The Labels do not need listeners because they generate no actions. The bottom TextField does not need a listener because it will have its text set by the program (this is not an event.) Here is the application. Decide what should go in place of the ten buttons:

import java.awt.*; 
import java.awt.event.*;

public class Repeater extends Frame implements ActionListener
{

Label inLabel = new (" " ) ;
TextField inText = new TextField( 15 );
Label outLabel = new (" " ) ;
TextField outText = new TextField( 15 ); Repeater() // constructor { setLayout( new FlowLayout() );
add( ) ;
add( ) ;
add( ) ;
add( ) ;
inText.addActionListener( ) ;
} public void actionPerformed( ActionEvent evt) { String name = inText.getText();
outText.( name );
repaint(); } public static void main ( String[] args ) { . . . . . . } } . . . . . .

Click on a button to see what should go there. (This may not work on some web browsers. The text-only version of the program is in the next page.)

QUESTION 9:

How many of the ten blanks (buttons) did you get correct?

Click Here after you have answered the question