Question: 4 . Create a new package inside your project called view. 5 . In the view package create a class called MainWindow and make it

4. Create a new package inside your project called view.
5. In the view package create a class called MainWindow and make it inherit from the
JFrame class.
6. In the MainWindow class create the following private attributes:
JDesktopPane desktop
JMenuBar menuBar
JMenu file (Menu title should be File)
JMenu edit (Menu title should be Edit)
JMenuItem menuItemTextDocument (Menu item title should be Text
Document)
Page 2 of 5
JMenuItem menuItemSpreadSheet (Menu item title should be Spreadsheet)
JMenuItem menuItemSave (Menu item title should be Save)
MenuItem menuAbout (Menu item title should be About)
MenuItem menuOpen (Menu item title should be Open)
MenuItem menuClose (Menu item title should be Close)
TrayIcon trayIcon
PopupMenu popup.
7. In the MainWindow class create the following methods (all methods will have a return
type of void and accept no parameters):
initializeComponents(),
addMenuItemsToPopup(),
addMenuItemsToMenu(),
addMenusToMenuBar(),
addComponentsToWindow(),
setWindowProperties()
registerListeners()
8. In the initializeComponents method initialize each of the private attributes using either
the default or primary constructor.
Use the setMnemonic method inside the file menu object to bind the letter A to
the file menu option and
Use the setMnemonic method inside the edit menu object to bind the letter S to
the edit menu option.
Use the setToolTipText method inside the save menu item object to set the tooltip
text "Saves the active document" for the save menu item.
Use the setPopupMenu method from the TrayIcon class to add the PopupMenu
to the trayIcon variable. Please note that the image to be used for the tray icon
will be the one you downloaded.
9. Inside the addMenuItemsToPopup method add the following to the PopupMenu:
menuAbout,
menuOpen
Page 3 of 5
menuClose
(There exists an add method inside the PopupMenu class).
10.Inside the addMenuItemsToMenu method:
add the menuItemTextDocument and menuItemSpreadSheet to the file menu.
add the menuItemSave to the edit menu.
(There exists an add method inside the JMenu class).
11. Inside the addMenusToMenuBar method add the file and edit menu to the menuBar.
(There exists an add method inside the JMenuBar class).
12. Inside the addComponentsToWindow method add the desktop pane to the JFrame.
Create two new classes SpreadSheetDocumentFrame and TextDocumentFrame inside
your view package. Both classes should inherit from JInternalFrame. Both classes
should have only one private attribute of type JTextArea. Create an intializeComponent
method that initializes the text area (you can use either the default or primary
constructor), then create an addComponentsToWindow inside of which you need to add
the text area to the frame.
15. Inside both newly created classes, create a setWindowsProperties method (no
parameters and return type void) and set the window size to be width 300 and height
300 and visibility to be true.
16. For both classes created above create a default constructor that will call the parents
primary constructor (please use the following primary constructor super(FRAME
TITLE, true, true, true, true) and swap out the frame title with any title you wish) and
then call the other created methods.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!