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.

public class TwoButtons extends JFrame implements ActionListener
  JButton redButton ;
  JButton grnButton ;

  // constructor for TwoButtons
  public TwoButtons()                           
    redButton = new JButton("Red");
    grnButton = new JButton("Green");
    getContentPane().setLayout( new FlowLayout() ); 
    getContentPane().add( redButton );                      
    getContentPane().add( grnButton );
    // register the buttonDemo frame
    // (the frame this constructor is making)
    // as the listener for both Buttons.
    redButton.addActionListener( this );
    grnButton.addActionListener( this );
    _________.setActionCommand( _______ );    
    _________.setActionCommand( _______ );    

  . . . .


Fill in the blanks.

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