A good answer might be:

  1. A new class that extends WindowAdapter needs to be defined,
  2. an object of that type needs to be constructed, and
  3. the object needs to be registered as a listener for window events.

WindowAdapter

The program has been expanded with more blanks for you to fill code that does those three things.

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
     add( redButton );                      
     add( grnButton );                      
  }

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

  public static void main ( String[] args )
  {
    TwoButtons demo  = new TwoButtons() ;
    
    _______________wquit = new _______________(); // 2 
    demo._______________( wquit ); // 3 
    
    demo.setSize( 200, 150 );     
    demo.setVisible( true );      

  }
}

class  ______________  extends ______________  // 1 
{
  public void windowClosing( WindowEvent e )
  {
    System.______________( 0 );  // what to do for this event--exit the program
  }
}

QUESTION 9:

Fill in the blanks. You can think of your own name for the new class.

Click Here after you have answered the question