A good answer might be:

The answer is given in the completed program, below.

Complete Program

The following is a complete program, suitable for copying to Notepad and running.

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

public class buttonDemo extends Frame implements ActionListener
{
  Button bChange = new Button("Click Me!"); // construct a Button

  buttonDemo()                           // constructor for buttonDemo
  {
    setLayout( new FlowLayout() );       // choose the layout manager 
    bChange.addActionListener( this );   // register the buttonDemo object 
                                         // as the listener for its Button.
    add( bChange );                      // add the button to the container
  }
   
  public void actionPerformed( ActionEvent evt)
  {
    setBackground( Color.blue );
    repaint();                           // ask the system to paint the screen.
  }

  public static void main ( String[] args )
  {
    buttonDemo frm = new buttonDemo();
    
    WindowQuitter wquit = new WindowQuitter();
    frm.addWindowListener( wquit );
    
    frm.setSize( 200, 150 );     
    frm.setVisible( true );      

  }
}

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

The repaint() method asks the system to paint the screen again. Notice that paint() is not called directly. The repaint() method tells the system that it will have to repaint the screen sometime soon (because we have changed something.) The system will call paint() at the appropriate time. This is different than calling paint() directly.

QUESTION 10:

Is there a paint() method for this buttonDemo frame?

Click Here after you have answered the question