Package edu.cnu.mdi.ui.menu
Class MenuManager
java.lang.Object
edu.cnu.mdi.ui.menu.MenuManager
Singleton registry for the application's menu bar and named menus.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddContribution(MenuContribution contribution) Add a menu under a stable ID and order it relative to other contributions.voidAdd a menu to the main menu bar.static MenuManagercreateMenuManager(JMenuBar menubar) Public access for the singleton.Get the file menu.static MenuManagerThis one is used after the menu manager is created.Gets a contributed menu without depending on its display label.Get a menu based on its name.voidremoveMenu(JMenu menu) Remove an unwanted menu from the menu barstatic voidsetFileMenu(JMenu menu) Set the file menu
-
Method Details
-
createMenuManager
Public access for the singleton.Only the first call actually creates the instance. Once the singleton exists, subsequent calls silently ignore the passed-in
menubarand return the original instance, still bound to whichever menu bar was passed the first time.- Parameters:
menubar- the main menu bar; only used on the first call- Returns:
- the menu manager for the one and only BaseMDIApplication.
-
getInstance
This one is used after the menu manager is created. Then you can add menus to the main frame without a reference to it.- Returns:
- the menu manager for the one and only BaseMDIApplication.
-
addMenu
Add a menu to the main menu bar.- Parameters:
menu- the menu to add.
-
getMenu
Get a menu based on its name.- Parameters:
text- the name of the menu, e.g., "File".- Returns:
- the menu, if it finds it.
-
getFileMenu
Get the file menu.- Returns:
- the file menu, if it has been set.
-
removeMenu
Remove an unwanted menu from the menu bar- Parameters:
menu- the menu to remove
-
setFileMenu
Set the file menu- Parameters:
menu- the file menu
-