A good answer might be:

An ordinary Button could be used.

Design of a New Program

An ordinary Button (a Button object of the Button 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:

  • has a frame that contains one Button.
    • The frame will be a listener for the button.
    • The frame will implement ActionListener.
  • Clicking on the Button will exit the program.
    • The actionPerformed() method will call System.exit( 0 ).
  • Clicking on the "close button" of the frame will do nothing.
    • This program will not have a listener for window events.

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

QUESTION 14:

Which two base classes from the Java AWT will be used in the program?    

Click Here after you have answered the question