Alicia creates a button using the code JButton exitButton = new JButton("exit"); and places it into a JFrame named mainFrame
using mainFrame.add(exitButton); When Alicia runs her code, she verifies that the button can be clicked as evidenced by it changing appearance when she attempts to click on it. However, clicking on the button does not cause the
program to exit.
A. Explain why JButton has built-in functionality to change appearance when exitButton is clicked.
B. Explain why JButton does not have built-in functionality to cause the program to exit when exitButton is clicked
Alicia decides to add functionality to her program so that it exits when exitButton is clicked.
is clicked.
C. Explain the type of class Alicia should define to add this functionality.
D Explain the method(s) that the class needs in order to provide this functionality.
E. Explain how many objects of that class will need to be created to provide this functionality.
F. Explain how that object/those objects will be connected to Alicia's previous code to provide
this functionality
Phil takes the code written by Alicia in Question 1 and decides to add a window that pops up after exitButton is pressed but before the program exits in order to confirm that the user really wishes to exit the program.
A. Alicia tells Phil to be sure that the new window is modal.
Explain what 'modal' means in this context and why it is appropriate to make this window modal.
B. Explain an appropriate component for Phil to use for this window.
C. Explain how Phil will need to modify Alicia's code to incorporate this new window and its new
functionality.