Class MenuSelectionManager

java.lang.Object
javax.swing.MenuSelectionManager

public class MenuSelectionManager extends Object
A MenuSelectionManager owns the selection in menu hierarchy.
Since:
1.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ChangeEvent
    Only one ChangeEvent is needed per button model instance since the event's only state is the source property.
    The collection of registered listeners
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a MenuSelectionManager.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a ChangeListener to the button.
    void
    Tell the menu selection to close and unselect all the menu components.
    componentForPoint(Component source, Point sourcePoint)
    Returns the component in the currently selected path which contains sourcePoint.
    Returns the default menu selection manager.
    protected void
    Notifies all listeners that have registered interest for notification on this event type.
    Returns an array of all the ChangeListeners added to this MenuSelectionManager with addChangeListener().
    Returns the path to the currently selected menu item
    boolean
    Return true if c is part of the currently used menu
    void
    When a MenuElement receives an event from a KeyListener, it should never process the event directly.
    void
    When a MenuElement receives an event from a MouseListener, it should never process the event directly.
    void
    Removes a ChangeListener from the button.
    void
    Changes the selection in the menu hierarchy.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
    boolean
    Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    int
    Answers an integer hash code for the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    Answers a string containing a concise, human-readable description of the receiver.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(long time)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(long time, int frac)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
  • Field Details

    • changeEvent

      protected transient ChangeEvent changeEvent
      Only one ChangeEvent is needed per button model instance since the event's only state is the source property. The source of events generated is always "this".
    • listenerList

      protected EventListenerList listenerList
      The collection of registered listeners
  • Constructor Details

    • MenuSelectionManager

      public MenuSelectionManager()
      Constructs a MenuSelectionManager.
  • Method Details

    • defaultManager

      public static MenuSelectionManager defaultManager()
      Returns the default menu selection manager.
      Returns:
      a MenuSelectionManager object
    • setSelectedPath

      public void setSelectedPath(MenuElement[] path)
      Changes the selection in the menu hierarchy. The elements in the array are sorted in order from the root menu element to the currently selected menu element.

      Note that this method is public but is used by the look and feel engine and should not be called by client applications.

      Parameters:
      path - an array of MenuElement objects specifying the selected path
    • getSelectedPath

      public MenuElement[] getSelectedPath()
      Returns the path to the currently selected menu item
      Returns:
      an array of MenuElement objects representing the selected path
    • clearSelectedPath

      public void clearSelectedPath()
      Tell the menu selection to close and unselect all the menu components. Call this method when a choice has been made
    • addChangeListener

      public void addChangeListener(ChangeListener l)
      Adds a ChangeListener to the button.
      Parameters:
      l - the listener to add
    • removeChangeListener

      public void removeChangeListener(ChangeListener l)
      Removes a ChangeListener from the button.
      Parameters:
      l - the listener to remove
    • getChangeListeners

      public ChangeListener[] getChangeListeners()
      Returns an array of all the ChangeListeners added to this MenuSelectionManager with addChangeListener().
      Returns:
      all of the ChangeListeners added or an empty array if no listeners have been added
      Since:
      1.4
    • fireStateChanged

      protected void fireStateChanged()
      Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.
      See Also:
    • processMouseEvent

      public void processMouseEvent(MouseEvent event)
      When a MenuElement receives an event from a MouseListener, it should never process the event directly. Instead all MenuElements should call this method with the event.
      Parameters:
      event - a MouseEvent object
    • componentForPoint

      public Component componentForPoint(Component source, Point sourcePoint)
      Returns the component in the currently selected path which contains sourcePoint.
      Parameters:
      source - The component in whose coordinate space sourcePoint is given
      sourcePoint - The point which is being tested
      Returns:
      The component in the currently selected path which contains sourcePoint (relative to the source component's coordinate space. If sourcePoint is not inside a component on the currently selected path, null is returned.
    • processKeyEvent

      public void processKeyEvent(KeyEvent e)
      When a MenuElement receives an event from a KeyListener, it should never process the event directly. Instead all MenuElements should call this method with the event.
      Parameters:
      e - a KeyEvent object
    • isComponentPartOfCurrentMenu

      public boolean isComponentPartOfCurrentMenu(Component c)
      Return true if c is part of the currently used menu
      Parameters:
      c - a Component
      Returns:
      true if c is part of the currently used menu, false otherwise