Class SwingPopupMenuBuilder

  • All Implemented Interfaces:
    net.sf.jguiraffe.gui.builder.action.PopupMenuBuilder

    public class SwingPopupMenuBuilder
    extends net.sf.jguiraffe.gui.builder.action.AbstractPopupMenuBuilder

    A specialized implementation of the PopupMenuBuilder interface for constructing Swing popup menus.

    This implementation creates a javax.swing.JPopupMenu object when a new builder instance is created. The several add() methods populate this menu. They expect that objects compatible with Swing are passed as parameters (e.g. Swing actions or Swing menu components).

    The create() method returns the current popup menu. It also displays the menu for the affected component (this component and the location where to display the popup must be specified at construction time).

    Version:
    $Id: SwingPopupMenuBuilder.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Summary

      Constructors 
      Constructor Description
      SwingPopupMenuBuilder​(MouseEvent event)
      Deprecated.
      Use the constructor which expects information about an ActionManager; this constructor only creates a partly initialized object.
      SwingPopupMenuBuilder​(net.sf.jguiraffe.gui.builder.action.ActionManager actMan, net.sf.jguiraffe.gui.builder.action.ActionBuilder builder, MouseEvent event)
      Creates a new instance of SwingPopupMenuBuilder and initializes it with information about the action manager to be delegated to and the mouse event that triggered the invocation of this builder.
    • Constructor Detail

      • SwingPopupMenuBuilder

        public SwingPopupMenuBuilder​(net.sf.jguiraffe.gui.builder.action.ActionManager actMan,
                                     net.sf.jguiraffe.gui.builder.action.ActionBuilder builder,
                                     MouseEvent event)
        Creates a new instance of SwingPopupMenuBuilder and initializes it with information about the action manager to be delegated to and the mouse event that triggered the invocation of this builder.
        Parameters:
        actMan - the ActionManager
        builder - the ActionBuilder
        event - the triggering event (must not be null)
        Throws:
        IllegalArgumentException - if the event is null
      • SwingPopupMenuBuilder

        @Deprecated
        public SwingPopupMenuBuilder​(MouseEvent event)
        Deprecated.
        Use the constructor which expects information about an ActionManager; this constructor only creates a partly initialized object.
        Creates a new instance of SwingPopupMenuBuilder and initializes it with the triggering mouse event.
        Parameters:
        event - the triggering event (must not be null)
        Throws:
        IllegalArgumentException - if the event is null
    • Method Detail

      • getTriggeringEvent

        public MouseEvent getTriggeringEvent()
        Returns the event that triggered the invocation of this builder.
        Returns:
        the triggering mouse event
      • create

        public Object create()
        Displays the popup menu constructed by this builder. This method must be called when the construction of the menu is complete.
        Returns:
        the popup menu
      • getMenu

        protected JPopupMenu getMenu()
        Returns the menu that is constructed by this builder.
        Returns:
        the current menu
      • showMenu

        protected void showMenu​(JPopupMenu m)
        Displays the specified popup menu. This method is called by create() with the current menu. This implementation displays the popup menu as specified by the triggering event.
        Parameters:
        m - the menu to display
      • getMenuUnderConstruction

        protected Object getMenuUnderConstruction()
        Specified by:
        getMenuUnderConstruction in class net.sf.jguiraffe.gui.builder.action.AbstractPopupMenuBuilder