Class BaseMenu

    • Constructor Detail

      • BaseMenu

        public BaseMenu()
        Constructs a new BaseMenu with no text.
      • BaseMenu

        public BaseMenu​(String s)
        Constructs a new BaseMenu with the supplied string as its text.
        Parameters:
        s - the text for the menu label
      • BaseMenu

        public BaseMenu​(Action a)
        Constructs a menu whose properties are taken from the Action supplied.
        Parameters:
        a - an Action
      • BaseMenu

        public BaseMenu​(String s,
                        boolean b)
        Constructs a new BaseMenu with the supplied string as its text and specified as a tear-off menu or not.
        Parameters:
        s - the text for the menu label
        b - can the menu be torn off (not yet implemented)
    • Method Detail

      • add

        public JMenuItem add​(Action a)
        Creates a new menu item attached to the specified Action object and appends it to the end of this menu.
        Overrides:
        add in class JMenu
        Parameters:
        a - the Action for the menu item to be added
        See Also:
        Action
      • insert

        public JMenuItem insert​(Action a,
                                int pos)
        Inserts a new menu item attached to the specified Action object at a given position.
        Overrides:
        insert in class JMenu
        Parameters:
        a - the Action object for the menu item to add
        pos - an integer specifying the position at which to add the new menu item
        Throws:
        IllegalArgumentException - if the value of pos < 0
      • sort

        public void sort()
        Sorts the menu items alphabetically.
      • createCascadingMenu

        public static BaseMenu createCascadingMenu​(JMenuItem[] menuitems,
                                                   int max,
                                                   String more)
        Creates a cascading menu that has at most "max entries". Ones the threshold is reached, a new submenu with the "more" label is introduced and subsequent entries are placed in their.
        Parameters:
        menuitems - the menuitems to create the menu from
        max - the maximum number of items (+ one for the "more") to show
        more - the text label for the sub-menu
        Returns:
        the menu
      • createCascadingMenu

        public static BaseMenu createCascadingMenu​(List<JMenuItem> menuitems,
                                                   int max,
                                                   String more)
        Creates a cascading menu that has at most "max entries". Ones the threshold is reached, a new submenu with the "more" label is introduced and subsequent entries are placed in their.
        Parameters:
        menuitems - the menuitems to create the menu from
        max - the maximum number of items (+ one for the "more") to show, use -1 for automatic maximum based on screen size
        more - the text label for the sub-menu
        Returns:
        the menu