A good answer might be:

  1. How many container objects will there be?
    • Just one---the frame.
  2. What GUI component objects will it contain?
    • The "Red" button and the "Green" button.
  3. What objects generate events?
    • Both buttons and the frame.
  4. What objects will receive the events?
    • A listener for window events, and
    • A listener for button events.

The Container Class

You might have said that each button will need its own listener. That would be an OK answer, but that is not how we are going to do it. First we need to write a class definition for the container frame. Here is a skeleton:

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

public class TwoButtons extends  ___________ implements  ____________
{


  . . . . more code will go here . . . . 

  public static void main ( String[] args )
  {
    TwoButtons demo  = new __________ ;
    

    . . . . more code will go here . . . . 
    
    demo.setSize( 200, 150 );     
    demo.setVisible( true );      

  }
}

. . . . more code will go here . . . . 

For now, just decide what class this new one extends and what interface it will implement. Then fill in the constructor in main()

QUESTION 4:

Fill in the blanks.           

Click Here after you have answered the question