- java.lang.Object
-
- javax.swing.MenuSelectionManager
-
public class MenuSelectionManager extends Object
A MenuSelectionManager owns the selection in menu hierarchy.
-
-
Field Summary
Fields Modifier and Type Field and Description protected ChangeEventchangeEventOnly one ChangeEvent is needed per button model instance since the event's only state is the source property.protected EventListenerListlistenerList
-
Constructor Summary
Constructors Constructor and Description MenuSelectionManager()
-
Method Summary
Methods Modifier and Type Method and Description voidaddChangeListener(ChangeListener l)Adds a ChangeListener to the button.voidclearSelectedPath()Tell the menu selection to close and unselect all the menu components.ComponentcomponentForPoint(Component source, Point sourcePoint)Returns the component in the currently selected path which contains sourcePoint.static MenuSelectionManagerdefaultManager()Returns the default menu selection manager.protected voidfireStateChanged()Notifies all listeners that have registered interest for notification on this event type.ChangeListener[]getChangeListeners()Returns an array of all theChangeListeners added to this MenuSelectionManager with addChangeListener().MenuElement[]getSelectedPath()Returns the path to the currently selected menu itembooleanisComponentPartOfCurrentMenu(Component c)Return true if c is part of the currently used menuvoidprocessKeyEvent(KeyEvent e)When a MenuElement receives an event from a KeyListener, it should never process the event directly.voidprocessMouseEvent(MouseEvent event)When a MenuElement receives an event from a MouseListener, it should never process the event directly.voidremoveChangeListener(ChangeListener l)Removes a ChangeListener from the button.voidsetSelectedPath(MenuElement[] path)Changes the selection in the menu hierarchy.
-
-
-
Field Detail
-
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
-
-
Method Detail
-
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 ofMenuElementobjects 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 theChangeListeners 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:
EventListenerList
-
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 givensourcePoint- 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
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
06/10/2025 10:48:45 Cette version de la page est en cache (à la date du 06/10/2025 10:48:45) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 30/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/MenuSelectionManager.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.