Class MenuUtils


  • public class MenuUtils
    extends java.lang.Object
    Utility class implementing menu related functions.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void disposeMenuElement​(@NotNull javax.swing.MenuElement menuElement)
      Remove all actions attached to menu entries in a given menu element and its children.
      static @Nullable javax.swing.JMenu findMenu​(@NotNull javax.swing.MenuElement menuElement, @NotNull java.lang.String key)
      Returns a JMenu by action key.
      static @Nullable javax.swing.JMenu getMenu​(@NotNull javax.swing.JMenuBar menuBar, @NotNull java.lang.String name)
      Returns a named JMenu entry of a JMenuBar.
      static void removeAll​(@NotNull javax.swing.JMenu menu)
      Remove all menu entries.
      static void removeAllFromSeparator​(@NotNull javax.swing.JMenu menu)
      Remove all menu entries from (but not including) the last separator.
      static void removeAllToSeparator​(@NotNull javax.swing.JMenu menu)
      Remove all menu entries up to (but not including) the first separator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • disposeMenuElement

        public static void disposeMenuElement​(@NotNull
                                              @NotNull javax.swing.MenuElement menuElement)
        Remove all actions attached to menu entries in a given menu element and its children.
        Parameters:
        menuElement - the menu element to process
      • removeAll

        public static void removeAll​(@NotNull
                                     @NotNull javax.swing.JMenu menu)
        Remove all menu entries.
        Parameters:
        menu - the menu to remove the entries from
      • removeAllToSeparator

        public static void removeAllToSeparator​(@NotNull
                                                @NotNull javax.swing.JMenu menu)
        Remove all menu entries up to (but not including) the first separator.
        Parameters:
        menu - the menu to remove the entries from
      • removeAllFromSeparator

        public static void removeAllFromSeparator​(@NotNull
                                                  @NotNull javax.swing.JMenu menu)
        Remove all menu entries from (but not including) the last separator.
        Parameters:
        menu - the menu to remove the entries from
      • getMenu

        @Nullable
        public static @Nullable javax.swing.JMenu getMenu​(@NotNull
                                                          @NotNull javax.swing.JMenuBar menuBar,
                                                          @NotNull
                                                          @NotNull java.lang.String name)
        Returns a named JMenu entry of a JMenuBar.
        Parameters:
        menuBar - the menu bar
        name - the name
        Returns:
        the menu or null if not found
      • findMenu

        @Nullable
        public static @Nullable javax.swing.JMenu findMenu​(@NotNull
                                                           @NotNull javax.swing.MenuElement menuElement,
                                                           @NotNull
                                                           @NotNull java.lang.String key)
        Returns a JMenu by action key.
        Parameters:
        menuElement - the menu element to search for the action key
        key - the action key to search
        Returns:
        the menu or null if not found