Eine gute Antwort könnte sein:

A JButton could be used.

New Program

A JButton generates actionEvents and needs an ActionListener that implements actionPerformed(). The actionPerformed() method can call System.exit(0) to exit the program.

Let us write a program that:

Often a real application has several ways to quit: the close window button, a menu selection, and perhaps a button like this program.


Which two GUI classes are needed for the program?