|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.browsecode.helpers.menus.MenuBarHelper
public class MenuBarHelper
Easily create platform-independent menus, where different parts of the application can manage their menus by themselves.
This does 2 major things:
1) Makes the menus cross-platform. Specifically, it handles (a) special locations for menus on Mac OS X (quit, prefs, and about are in the application menu), and on Windows, "Quit" should say "Exit", and on Unix, this makes the quit item say "Quit"
2) This allows you to component-ize your program into different chunks, each that have their own set of menus. MenuBarHelper will merge them all into one menu bar.
It also makes sure there are no duplicate menu items.
For example, if you use an HTML component, you can do "menuBarHelper.addHasMenus(new
" and suddenly you have a "Format" menu for editing in HTML components, and several items will be automatically added to "Edit".
It works the same way if you use UndoHandler -- it will automatically add undo and redo items to the edit menu.
In the future, this will also do some automatic Translation for your menus -- standard menu and item names will automatically be translated into languages besides english (for any languages which locale files are made), and the code will still be refer to them by the english name.
HTMLEditingMenus
());
Nested Class Summary | |
---|---|
static class |
MenuBarHelper.MenuItemComparator
|
static class |
MenuBarHelper.MenuItemComparatorStartsWith
|
Field Summary |
---|
Fields inherited from interface org.browsecode.helpers.menus.HasMenus.ActiveListener |
---|
ACTIVE, INACTIVE, INVISIBLE |
Constructor Summary | |
---|---|
MenuBarHelper()
Application name is optional, but on MacOS X it is strongly recommended for the Application menu's title. |
Method Summary | |
---|---|
void |
activeChanged(HasMenus hasMenus,
int isNowActive)
Call this whenever the HasMenus becomes active or inactive. |
void |
addHasMenus(HasMenus hasMenus)
|
protected void |
addMenuInRightPlace(MenuJMenu menu)
|
void |
addQuitListener(QuitListener quitListener)
Add a QuitListener . |
boolean |
fireQuitEvent()
|
MenuItem |
getAboutMenuItem()
Get the "About ..." |
protected Menu |
getFileMenu()
|
Menu |
getMenu(java.lang.String menuName)
|
javax.swing.JMenuBar |
getMenuBar()
|
java.util.Vector |
getMenuOrder()
Get order of Menus, from left to right. |
Translator |
getTranslator()
|
boolean |
removeQuitListener(QuitListener quitListener)
|
void |
setMenuOrder(java.util.Vector newMenuOrder)
Set the order of the Menus, from left to right. |
void |
setTranslator(Translator translator)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MenuBarHelper()
applicationName
- Method Detail |
---|
public java.util.Vector getMenuOrder()
public Translator getTranslator()
public void setTranslator(Translator translator)
public void setMenuOrder(java.util.Vector newMenuOrder)
newMenuOrder
- protected void addMenuInRightPlace(MenuJMenu menu)
protected Menu getFileMenu()
public javax.swing.JMenuBar getMenuBar()
public Menu getMenu(java.lang.String menuName)
public void addHasMenus(HasMenus hasMenus)
public MenuItem getAboutMenuItem()
public void addQuitListener(QuitListener quitListener)
QuitListener
. This will be notificed if the user quits. Also will make sure the quit item exists in the menus.
This is global -- anytime "Quit" is selected, all QuitListeners anywhere in the JVM will be notified. This is intentional (the list of QuitListeners is static).
quitListener
- public boolean removeQuitListener(QuitListener quitListener)
public boolean fireQuitEvent()
public void activeChanged(HasMenus hasMenus, int isNowActive)
HasMenus.ActiveListener
activeChanged
in interface HasMenus.ActiveListener
hasMenus
- the HasMenus that fired this eventisNowActive
- whether or not the HasMenus is currently active
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |