APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing

public Class MenuSelectionManager

extends Object
Class Inheritance
Imports
java.awt.*, java.util.*, java.awt.event.*, javax.swing.event.*, sun.awt.AWTAccessor, .AWTAccessor.MouseEventAccessor, sun.swing.SwingUtilities2

A MenuSelectionManager owns the selection in menu hierarchy.
Author
Arnaud Weber
Since
1.2

Field Summary

Modifier and TypeField and Description
protected transient ChangeEvent
changeEvent

Only one ChangeEvent is needed per button model instance since the event's only state is the source property.

private static final boolean
private static final MenuSelectionManager
protected EventListenerList
listenerList

The collection of registered listeners

private Vector<MenuElement>
private static final boolean
private static final boolean

Constructor Summary

AccessConstructor and Description

Method Summary

Modifier and TypeMethod and Description
public void
addChangeListener(ChangeListener
the listener to add
l
)

Adds a ChangeListener to the button.

public void
clearSelectedPath()

Tell the menu selection to close and unselect all the menu components.

public Component

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.
componentForPoint
(Component
The component in whose coordinate space sourcePoint is given
source
,
Point
The point which is being tested
sourcePoint
)

Returns the component in the currently selected path which contains sourcePoint.

public static MenuSelectionManager

Returns:

a MenuSelectionManager object
defaultManager
()

Returns the default menu selection manager.

protected void
fireStateChanged()

Notifies all listeners that have registered interest for notification on this event type.

public ChangeListener[]

Returns:

all of the ChangeListeners added or an empty array if no listeners have been added
getChangeListeners
()

Returns an array of all the ChangeListeners added to this MenuSelectionManager with addChangeListener().

public MenuElement[]

Returns:

an array of MenuElement objects representing the selected path
getSelectedPath
()

Returns the path to the currently selected menu item

public boolean

Returns:

true if c is part of the currently used menu, false otherwise
isComponentPartOfCurrentMenu
(Component
a Component
c
)

Return true if c is part of the currently used menu

private boolean
private void
private void
printMenuElementArray(MenuElement[] path, boolean dumpStack)

public void
processKeyEvent(KeyEvent
a KeyEvent object
e
)

When a MenuElement receives an event from a KeyListener, it should never process the event directly.

public void
processMouseEvent(MouseEvent
a MouseEvent object
event
)

When a MenuElement receives an event from a MouseListener, it should never process the event directly.

public void
removeChangeListener(ChangeListener
the listener to remove
l
)

Removes a ChangeListener from the button.

public void
setSelectedPath(MenuElement[]
an array of MenuElement objects specifying the selected path
path
)

Changes the selection in the menu hierarchy.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

changeEventback to summary
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".

DEBUGback to summary
private static final boolean DEBUG
DEFAULT_MSMback to summary
private static final MenuSelectionManager DEFAULT_MSM
listenerListback to summary
protected EventListenerList listenerList

The collection of registered listeners

selectionback to summary
private Vector<MenuElement> selection
TRACEback to summary
private static final boolean TRACE
VERBOSEback to summary
private static final boolean VERBOSE

Constructor Detail

Method Detail

addChangeListenerback to summary
public void addChangeListener(ChangeListener l)

Adds a ChangeListener to the button.

Parameters
l:ChangeListener

the listener to add

clearSelectedPathback to summary
public void clearSelectedPath()

Tell the menu selection to close and unselect all the menu components. Call this method when a choice has been made

componentForPointback to summary
public Component componentForPoint(Component source, Point sourcePoint)

Returns the component in the currently selected path which contains sourcePoint.

Parameters
source:Component

The component in whose coordinate space sourcePoint is given

sourcePoint:Point

The point which is being tested

Returns:Component

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.

defaultManagerback to summary
public static MenuSelectionManager defaultManager()

Returns the default menu selection manager.

Returns:MenuSelectionManager

a MenuSelectionManager object

fireStateChangedback to summary
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
getChangeListenersback to summary
public ChangeListener[] getChangeListeners()

Returns an array of all the ChangeListeners added to this MenuSelectionManager with addChangeListener().

Returns:ChangeListener[]

all of the ChangeListeners added or an empty array if no listeners have been added

Since
1.4
getSelectedPathback to summary
public MenuElement[] getSelectedPath()

Returns the path to the currently selected menu item

Returns:MenuElement[]

an array of MenuElement objects representing the selected path

isComponentPartOfCurrentMenuback to summary
public boolean isComponentPartOfCurrentMenu(Component c)

Return true if c is part of the currently used menu

Parameters
c:Component

a Component

Returns:boolean

true if c is part of the currently used menu, false otherwise

isComponentPartOfCurrentMenuback to summary
private boolean isComponentPartOfCurrentMenu(MenuElement root, Component c)
printMenuElementArrayback to summary
private void printMenuElementArray(MenuElement[] path)
printMenuElementArrayback to summary
private void printMenuElementArray(MenuElement[] path, boolean dumpStack)
processKeyEventback to summary
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:KeyEvent

a KeyEvent object

processMouseEventback to summary
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:MouseEvent

a MouseEvent object

Annotations
@SuppressWarnings:deprecation
removeChangeListenerback to summary
public void removeChangeListener(ChangeListener l)

Removes a ChangeListener from the button.

Parameters
l:ChangeListener

the listener to remove

setSelectedPathback to summary
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:MenuElement[]

an array of MenuElement objects specifying the selected path