Container and its Components
The setBackground( ) method is a member of
Repeater (which extends Frame).
So to use it in the constructor for Repeater,
you just use its name (as below).
public class Repeater extends Frame implements ActionListener
{
Label inLabel = new Label( "Enter Your Name: " ) ;
TextField inText = new TextField( 15 );
Label outLabel = new Label( "Here is Your Name :" ) ;
TextField outText = new TextField( 15 );
Repeater() // constructor
{
setLayout( new FlowLayout() ); // choose the layout manager
add( inLabel ) ;
add( inText ) ;
add( outLabel ) ;
add( outText ) ;
setBackground( Color.green );
inText.addActionListener( this );
outText.setEditable( false );
}
. . . . . .
}
|
The other methods addActionListener( ) and setEditable( )
are members of TextField objects that are contained
inside the Repeater container.
To use them you have to follow a reference to the particular object,
like this:
outText.setEditable( false );
|