Rewrite the program in Listing 13.10 so that it has all of the following changes:
• The class name is MemoSaver2.
• There are six buttons instead of five at the bottom of the GUI. They are arranged as follows:
Hint: Use the GridLayout manager on the button panel.
• When the user saves the text as the first memo, the text area changes so that it says Memo 1 saved, and when the second memo is saved, the text area changes to say Memo 2 saved. (See Self-Test Question 43 for a hint.)
• When the Exit button is clicked, the program ends, and the window goes away. The close-window button also ends the program. So the Exit button and the close-window button perform the same action.
• In addition to the default constructor, another constructor produces the same display, except that the text area can accommodate a given number of lines and characters per line. This constructor has the following form:
public MemoSaver2(int lineCount, int charCount)
• The text area has line wrap, so that if more characters are entered than will fit on the line, the extra characters automatically go on the next line.
• The method main constructs two windows, one using the default constructor and one using the added constructor with arguments 5 and 60, in that order.
This program can be created by modifying MemoSaver.java, Listing 13.10, but there is one potential problem with the display. Depending on the resolution of the user’s screen, the window size may be too small to show the complete text panel. If that happens, the first few characters typed into the text box will not be visible. This is a little disconcerting; unless enough characters are typed it will appear that the text box is not letting the user enter anything. Increasing the width of the window from 600 should fix the problem (changing it to 700 works for a screen resolution of 1024 by 768).
See the code in MemoSaver2.java. Uses WindowDestroyer.java.
You might also like to view...
During a code review a software developer discovers a security risk that may result in hundreds of hours of rework. The security team has classified these issues as low risk. Executive management has decided that the code will not be rewritten. This is an example of:
A. Risk avoidance B. Risk transference C. Risk mitigation D. Risk acceptance
____ size is measured in points (pt), with 10 pt being a typical size for text in the body of a document.
A. Text B. Face C. Type D. Font