A JButton could be used.
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:
ActionListener
by having an actionPerformed() method.
actionPerformed() method will call System.exit( 0 ).Often a real application has several ways to quit: the close window button, a menu selection, and perhaps a button like this program.