Answer:
It would not be unusual to miss a blank or two.
Complete Program
For such a complicated relationship diagram, this is a short program.
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ButtonQuitter extends JFrame implements ActionListener { JButton bQuit = new JButton("Click here to Exit"); public ButtonQuitter(String title) { super(title); setLayout( new FlowLayout() ); bQuit.addActionListener( this ); add( bQuit ); } public void actionPerformed( ActionEvent evt) { System.exit( 0 ); } public static void main ( String[] args ) { ButtonQuitter frame = new ButtonQuitter("Button Quitter"); frame.setSize( 200, 100 ); frame.setVisible( true ); } }
The program can be copied to a file, compiled and run in the usual way.
QUESTION 23:
How many times must you click the JButton for the program to exit?