A good answer might be:

It is one of the methods that each Button object has. (Buttons are objects, so they have identity, state, and behavior as do all objects.)

Setting Button Commands

Here is the program so far, but with some new blanks.

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

public class TwoButtons extends Frame implements ActionListener
{
  Button redButton = new Button("Red");
  Button grnButton = new Button("Green");

  TwoButtons()                            // constructor for TwoButtons
  {  
     setLayout( new FlowLayout() );       // choose the layout manager 
     redButton.addActionListener( this ); // register the buttonDemo object
     grnButton.addActionListener( this ); // with both Buttons. 
    
     _________.setActionCommand( _______ );    
     _________.setActionCommand( _______ );    

     add( redButton );                      
     add( grnButton );                      
  }

  public void actionPerformed( ActionEvent evt)
  {
                                         // we will soon do something new here
    repaint();                           // ask the system to paint the screen.
  }


  . . . . . . . .
}

You will need to fill in the blanks. Remeber that:

  1. Each button needs to have a command set for it.
  2. A command is a String.
  3. The commands must be unique.

QUESTION 13:

Fill in the blanks.

Click Here after you have answered the question