A good answer might be:

A JButton could be used.


New Program

An ordinary button (a button of the JButton class) 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.

QUESTION 18:

Which two GUI classes are needed for the program?