- 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 ChangeEvent
changeEvent
Only one ChangeEvent is needed per button model instance since the event's only state is the source property.protected EventListenerList
listenerList
-
Constructor Summary
Constructors Constructor and Description MenuSelectionManager()
-
Method Summary
Methods Modifier and Type Method and Description void
addChangeListener(ChangeListener l)
Adds a ChangeListener to the button.void
clearSelectedPath()
Tell the menu selection to close and unselect all the menu components.Component
componentForPoint(Component source, Point sourcePoint)
Returns the component in the currently selected path which contains sourcePoint.static MenuSelectionManager
defaultManager()
Returns the default menu selection manager.protected void
fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type.ChangeListener[]
getChangeListeners()
Returns an array of all theChangeListener
s added to this MenuSelectionManager with addChangeListener().MenuElement[]
getSelectedPath()
Returns the path to the currently selected menu itemboolean
isComponentPartOfCurrentMenu(Component c)
Return true if c is part of the currently used menuvoid
processKeyEvent(KeyEvent e)
When a MenuElement receives an event from a KeyListener, it should never process the event directly.void
processMouseEvent(MouseEvent event)
When a MenuElement receives an event from a MouseListener, it should never process the event directly.void
removeChangeListener(ChangeListener l)
Removes a ChangeListener from the button.void
setSelectedPath(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 ofMenuElement
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 theChangeListener
s added to this MenuSelectionManager with addChangeListener().- Returns:
- all of the
ChangeListener
s 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
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/menuselectionmanager.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.