Enhance the memo saver GUI in Listing 15.1 in all of the following ways:
• Add another menu called Scroll Bars that offers the user three choices: Never, Always, and As Needed. When the user makes a choice, the scroll bars are displayed according to the choice.
• When the user clicks the close-window button, another window pops up and asks the user whether to end the program, as was done in Listing 15.10.
This program is best done by adding one feature at a time and judiciously copying code from examples on the CD that comes with the text.
To obtain the exit pop-up window, start with the code from CloseWindowDemo, Listing 15.10 and add to it. For example, add a call to ConfirmWindow() in the actionPerformed method if the ActionEvent is “Exit”. The setDefaultCloseOperation code is necessary to get the pop-up window when the exit button (the “X” in the upper left corner of the window) is clicked, and the call in actionPerformed is necessary to get the window when “Close” in the “Memos” menu is selected.
Next, add the nested menus and make sure it works before actually coding the events for the options.
Next, add functionality to the “View” menu options.
Unfortunately, there is no program from which to copy the code to make the “Scroll Bars” options functional, but it is mostly a matter of going through “The JScrollPane Class for Scroll Bars” section of Chapter 15 and following the directions. Note that the following line is necessary to make the change visible immediately after selecting any of these options:
```
SwingUtilities.updateComponentTreeUI(this);
```
See the code in MemoGUIEnhanced.java.
You might also like to view...
Discuss the purpose of mapping.
What will be an ideal response?
Write a sequence of statements that determines and displays the smallest value in t.
What will be an ideal response?
When should a programmer select a do while loop for his or her program?
A. When he or she knows the exact number of times the loop will be executed. B. When he or she is not sure how many times the loop will be executed. C. When he or she knows the loop must be executed at least once. D. There is no reason to select a do while loop. Any loop can be used any time.
On Writer's Menu bar the ________ command enables the user to cut or copy text, find and replace text, and use AutoText
Fill in the blank(s) with correct word