Class RibbonApplicationMenu
JRibbon
component. The ribbon application menu has three parts:
+-------------------------------------+ | | | | | | | primary | secondary | | area | area | | | | | | | |-------------------------------------| | footer area | +-------------------------------------+
The entries in the primary area are always visible. The secondary area entries are shown based on the currently active element in the primary area. There are three different types of primary entries:
- Associated
ActionListenerpassed to the constructor of theRibbonApplicationMenuEntryPrimary. When this entry is armed (with mouse rollover or via keyboard navigation), the contents of the secondary area are cleared. TheQuitmenu item is an example of such a primary menu entry. - Associated
RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallbackset by theRibbonApplicationMenuEntryPrimary.setRolloverCallback(PrimaryRolloverCallback). When this entry is armed (with mouse rollover or via keyboard navigation), the contents of the secondary area are populated by the application callback implementation ofRibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback.menuEntryActivated(javax.swing.JPanel). TheOpenmenu item is an example of such a primary menu entry, showing a list of recently opened files. - Associated list of
RibbonApplicationMenuEntrySecondarys added with theRibbonApplicationMenuEntryPrimary.addSecondaryMenuGroup(String, RibbonApplicationMenuEntrySecondary...)API. When this entry is armed (with mouse rollover or via keyboard navigation), the secondary area shows menu buttons for the registered secondary menu entries. TheSave Asmenu item is an example of such a primary menu item, showing a list of default save formats.
At runtime, the application menu entries are implemented as
JCommandMenuButton, but the application code does not operate on that
level. Instead, the application code creates metadata-driven description of
the ribbon application menu, and that description is used to create and
populate the "real" controls of the application menu popup.
Note that once a RibbonApplicationMenu is set on the JRibbon
with the JRibbon.setApplicationMenu(RibbonApplicationMenu), its
contents cannot be changed. An IllegalStateException will be thrown
from addMenuEntry(RibbonApplicationMenuEntryPrimary) and
addFooterEntry(RibbonApplicationMenuEntryFooter).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified footer menu entry.voidAdds the specified primary menu entry.voidReturns the default callback of this ribbon application menu.Returns an unmodifiable list of all footer menu entries of this application menu.Returns an unmodifiable list of all primary menu entries of this application menu.voidSets the default callback to be called when: The ribbon application menu is first shown. The currently active (rollover) primary application menu entry has no secondary menu entries and no associated rollover callback.
-
Constructor Details
-
RibbonApplicationMenu
public RibbonApplicationMenu()Creates an empty ribbon application menu.
-
-
Method Details
-
addMenuEntry
Adds the specified primary menu entry.- Parameters:
entry- Primary menu entry to add.- Throws:
IllegalStateException- if this ribbon application menu has already been set on theJRibbonwith theJRibbon.setApplicationMenu(RibbonApplicationMenu).- See Also:
-
addMenuSeparator
public void addMenuSeparator() -
getPrimaryEntries
Returns an unmodifiable list of all primary menu entries of this application menu. The result is guaranteed to be non-null.- Returns:
- An unmodifiable list of all primary menu entries of this application menu.
- See Also:
-
setDefaultCallback
public void setDefaultCallback(RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback defaultCallback) Sets the default callback to be called when:- The ribbon application menu is first shown.
- The currently active (rollover) primary application menu entry has no secondary menu entries and no associated rollover callback.
- Parameters:
defaultCallback- Default callback.
-
getDefaultCallback
Returns the default callback of this ribbon application menu.- Returns:
- The default callback of this ribbon application menu.
- See Also:
-