public final class JMenuSorter
extends java.lang.Object
JMenu
in sorted order. The menu is maintained in sorted order even if items
are added or removed from the menu.
When a menu is registered with the JMenuSorter
, the
contents of each
If desired, one or more specific menu groups may be excluded from sorting for any menu that was registered for sorting. A menu group to be excluded from sorting is identified by any component in that menu group.
Modifier and Type | Method and Description |
---|---|
static boolean |
isSorted(javax.swing.JMenu menu)
Returns
true if the specified JMenu is registered
to be maintained in sorted order. |
static void |
registerExclusionGroup(javax.swing.JMenu menu,
java.awt.Component component)
Registers a menu group for a
JMenu so that the group will be
excluded from sorting. |
static void |
registerJMenu(javax.swing.JMenu menu)
Registers a
JMenu so that it will be maintained in sorted
order. |
static void |
unregisterExclusionGroup(javax.swing.JMenu menu,
java.awt.Component component)
Unegisters a menu group for a
JMenu so that the group will be
included in sorting. |
static void |
unregisterJMenu(javax.swing.JMenu menu)
Unregisters a
JMenu so that it will no longer be maintained in
sorted order. |
public static boolean isSorted(javax.swing.JMenu menu)
true
if the specified JMenu
is registered
to be maintained in sorted order.menu
- the menu whose sorting status is to be tested.public static void registerJMenu(javax.swing.JMenu menu)
JMenu
so that it will be maintained in sorted
order.menu
- the menu that should be maintained in sorted order.public static void unregisterJMenu(javax.swing.JMenu menu)
JMenu
so that it will no longer be maintained in
sorted order. This method should only be called for a menu that has
been registered for sorting with registerJMenu(JMenu)
, but it
is not an error if the menu was not so registered.menu
- the menu that should no longer be maintained in sorted
order.public static void registerExclusionGroup(javax.swing.JMenu menu, java.awt.Component component)
JMenu
so that the group will be
excluded from sorting. This method should only be called for a menu
that has been registered for sorting with registerJMenu(JMenu)
, but it is not an error if the menu was not so
registered.menu
- the menu that is being maintained in sorted order.component
- the component indicating the menu group that should
be excluded from sorting.public static void unregisterExclusionGroup(javax.swing.JMenu menu, java.awt.Component component)
JMenu
so that the group will be
included in sorting. This method should only be called for a menu
that has been registered for sorting with registerJMenu(JMenu)
, but it is not an error if the menu is not
registered.
It is an error to call this method if the specified menu and component
were not previously excluded from sorting by calling registerExclusionGroup(JMenu,Component)
.
menu
- the menu that is being maintained in sorted order.component
- the component in the menu group that was previously
excluded from sorting.