Eine gute Antwort könnte sein:

The blanks are filled in below:

Blanks filled In

public class ButtonDemo2 extends JFrame implements ActionListener
{
  JButton bChange;

  public ButtonDemo2()
  {
    getContentPane().setLayout( new FlowLayout() );
    bChange = new JButton("Click Me!");
    getContentPane().add( bChange );
  }

  public void actionPerformed( ActionEvent evt)
  {
     . . . . . .
  }

  public static void main ( String[] args )
  {
    ButtonDemo2 frm = new ButtonDemo2();
      . . . . .
  }
}

In this style of GUI programming, one object (the ButtonDemo2 object) is playing several roles: it is the container object, and it is also the listener object. However, implementing ActionListener is not enough. The listener must still be registered with the Button.

FRAGE 12:

(Review: ) What does registering a listener do?

Inhaltsverzeichnis