Class ContextualMenuHelper



  • public class ContextualMenuHelper
    extends Object
    • Constructor Detail

      • ContextualMenuHelper

        public ContextualMenuHelper()
      • ContextualMenuHelper

        public ContextualMenuHelper(JComponent jc)
    • Method Detail

      • add

        public static void add(JComponent jc,
                               String menuItemName,
                               Runnable runnable)
        Add a menu item that invokes the argument Runnable when selected.
        Parameters:
        runnable - this is invoked (via SwingUtilities.invokeLater()) when this menu item is selected.
      • getContextualMenuHelper

        public static ContextualMenuHelper getContextualMenuHelper(JComponent jc)
        Return the ContextualMenuHelper the static helper methods refer to.
        Parameters:
        jc - the component to retrieve a common ContextualMenuHelper for.
        Returns:
        the common ContextualMenuHelper for the argument. This will create one if it doesn't already exist.
      • addToggle

        public static void addToggle(JComponent jc,
                                     BooleanProperty property,
                                     Runnable runnable)
        Add a checkbox menu item to control a BooleanProperty.
        Parameters:
        runnable - this is invoked (via SwingUtilities.invokeLater()) when this menu item is selected.
      • addPopupMenu

        public static void addPopupMenu(String popupName,
                                        JComponent jc,
                                        EnumProperty<?> property,
                                        Runnable runnable)
        Add a submenu that offers a choice of radiobutton menu items to control an EnumProperty.
        Parameters:
        runnable - this is invoked (via SwingUtilities.invokeLater()) when any choice is selected.
      • addComponent

        public void addComponent(JComponent jc)
        Install this contextual menu on the component provided.
      • showPopup

        protected void showPopup(Component c,
                                 int x,
                                 int y)
      • clear

        public static void clear(JComponent component)
        Clear any registered contextual menu information for this component.
        Parameters:
        component - the component to purge all contextual menu info for.
      • addMenuItem

        public void addMenuItem(JMenuItem menuItem)
      • removeMenuItem

        public void removeMenuItem(JMenuItem menuItem)