Question: 4 . Create a new package inside your project called view. 5 . In the view package create a class called MainWindow and make it
Create a new package inside your project called view.
In the view package create a class called MainWindow and make it inherit from the
JFrame class.
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 of
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.
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
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.
Inside the addMenuItemsToPopup method add the following to the PopupMenu:
menuAbout,
menuOpen
Page of
menuClose
There exists an add method inside the PopupMenu class
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
Inside the addMenusToMenuBar method add the file and edit menu to the menuBar.
There exists an add method inside the JMenuBar class
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.
Inside both newly created classes, create a setWindowsProperties method no
parameters and return type void and set the window size to be width and height
and visibility to be true.
For both classes created above create a default constructor that will call the parents
primary constructor please use the following primary constructor superFRAME
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
