com.sas.swing.visuals
Class MenuBar

com.sas.swing.visuals.MenuBar
All Implemented Interfaces:
ForwardedActionSource, ForwardedItemSource, MultipleValueEventSourceInterface, java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.MenuElement

public class MenuBar
implements ForwardedActionSource, ForwardedItemSource, java.awt.ItemSelectable, java.awt.event.ItemListener, java.awt.event.ActionListener, MultipleValueEventSourceInterface

MenuBar is a sub-class of javax.swing.JMenuBar that sends out events when any of the JMenuItems on it are triggered. ForwardedActionEvents and ForwardedItemEvents are sent out. The individual JMenuItems are also accessable from their ActionCommands using this MenuBar.

Notes:


See Also:
Serialized Form

Field Summary
protected  ForwardedActionListenerList forwardedActionListenerList
          Manages a list of listeners for ForwardedActionEvent
protected  ForwardedItemListenerList forwardedItemListenerList
          Manages a list of listeners for ForwardedItemEvent
protected  java.awt.event.ItemListener itemListenerList
          ItemListener that listens to Item events
 
Constructor Summary
MenuBar()
          Constructor, empty and no initializing
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Handles ActionEvents from the JMenuItems on this MenuBar.
 javax.swing.JMenu add(javax.swing.JMenu m)
          Adds the specified menu to the menu bar.
 void addForwardedActionListener(ForwardedActionListener listener)
          Add an ForwardedActionListener to listen for ForwardedActionEvents on the MenuBar.
 void addForwardedItemListener(ForwardedItemListener listener)
          Adds a ForwardedItemListener to listen for ForwardedItemEvents on the BaseButton The events are sent whenever an ItemSelectable JMenuItem component sends out an ForwardedItemEvent.
 void addItemListener(java.awt.event.ItemListener listener)
          Adds an ItemListener to listen for ForwardedItemEvents on the MenuBar.
 void addListeners(javax.swing.JMenuItem menuItem, boolean parseMenu)
          Adds event listeners needed to the given JMenuItem.
 java.lang.reflect.Method getEventMethod(java.lang.reflect.Method lMethod)
          Gets the event method.
 java.lang.String[] getEventValues(java.lang.reflect.Method lMethod)
          Gets a string array of event values.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this MenuBar.
 javax.swing.JMenuItem[] getMenuItems(java.lang.String cmdStr)
          Get the JMenuItems that have the specified actionCommand String.
 java.lang.Object[] getSelectedObjects()
          Here for compatibility with the java.awt.ItemSelectable interface.
 void itemStateChanged(java.awt.event.ItemEvent evt)
          Handles ActionEvents from the ItemSelectable JMenuItems on this MenuBar.
protected  java.util.Enumeration parseCommands(javax.swing.JMenu currentMenu)
          Parses the JMenu to get and add action commands to an OrderedCollection, and returns enumeration of the action commands
protected  void parseMenu(javax.swing.JMenu currentMenu, boolean addListeners)
          Parses the JMenu to add or remove the MenuBar as a listener to any events sent out by JMenuItems on the given JMenu.
protected  java.util.Enumeration parseMenuCommands(javax.swing.JMenu currentMenu, java.lang.String cmdStr)
          Parses a JMenu to find any JMenuItems that use the specified actionCommand String.
protected  void processForwardedActionEvent(ForwardedActionEvent e)
          Process ForwardedActionEvents sent from the MenuBar to its ForwardedActionListeners.
protected  void processForwardedItemEvent(ForwardedItemEvent e)
          Process ForwardedItemEvents sent from the MenuBar to its ForwardedItemListeners.
protected  void processItemEvent(java.awt.event.ItemEvent e)
          Process ItemEvents sent from the MenuBar to its ItemListeners.
 void removeForwardedActionListener(ForwardedActionListener listener)
          Removes a ForwardedActionListener from the list of listeners to be notified of ForwardedActionEvents.
 void removeForwardedItemListener(ForwardedItemListener listener)
          Removes a ForwardedItemListener from the list of listeners to be notified of an ForwardedItemEvent.
 void removeItemListener(java.awt.event.ItemListener listener)
          Removes an ItemListener from the list of listeners to be notified of ForwardedItemEvents.
 void removeListeners(javax.swing.JMenuItem menuItem, boolean parseMenu)
          Removes event listeners from the given JMenuItem.
 void setMenuItemsEnabled(java.lang.String cmd, boolean enabled)
          Sets the JMenuItems with the specified actionCommand to the given enabled state.
 boolean supportsListenerInterface(java.lang.Class listenerInterface)
          Indicates whether the listenerInterface class passed in is a ForwardedActionListener .
 void updateJMenuItems()
          Parses all of the current JMenuItems and add the MenuBar as a listener to any events that they send out.
 

Field Detail

itemListenerList

protected transient java.awt.event.ItemListener itemListenerList
ItemListener that listens to Item events


forwardedActionListenerList

protected transient ForwardedActionListenerList forwardedActionListenerList
Manages a list of listeners for ForwardedActionEvent


forwardedItemListenerList

protected transient ForwardedItemListenerList forwardedItemListenerList
Manages a list of listeners for ForwardedItemEvent

Constructor Detail

MenuBar

public MenuBar()
Constructor, empty and no initializing

Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this MenuBar.

Returns:
the ExtendedBeanInfo for this class

add

public javax.swing.JMenu add(javax.swing.JMenu m)
Adds the specified menu to the menu bar. Also parses the JMenu and its items to add the JMenuBar as an ActionListener and an ItemListener if possible. This allows the JMenuBar to forward any menu events on to its listeners.

Overrides:
add in class javax.swing.JMenuBar

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Handles ActionEvents from the JMenuItems on this MenuBar.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - the ActionEvent that occurred

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent evt)
Handles ActionEvents from the ItemSelectable JMenuItems on this MenuBar.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
evt - the ItemEvent that changed

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Here for compatibility with the java.awt.ItemSelectable interface. Does nothing except return null

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
null

addForwardedActionListener

public void addForwardedActionListener(ForwardedActionListener listener)
Add an ForwardedActionListener to listen for ForwardedActionEvents on the MenuBar. The events are sent whenever a JMenuItem component sends out an ActionEvent.

Specified by:
addForwardedActionListener in interface ForwardedActionSource
Parameters:
listener - the ForwardedActionListener to send the ForwardedActionEvents to.
See Also:
ForwardedActionEvent, ForwardedActionListener, removeForwardedActionListener(com.sas.visuals.ForwardedActionListener)

removeForwardedActionListener

public void removeForwardedActionListener(ForwardedActionListener listener)
Removes a ForwardedActionListener from the list of listeners to be notified of ForwardedActionEvents.

Specified by:
removeForwardedActionListener in interface ForwardedActionSource
Parameters:
listener - the ForwardedActionListener to stop sending the ForwardedActionEvents to.
See Also:
ForwardedActionEvent, ForwardedActionListener, addForwardedActionListener(com.sas.visuals.ForwardedActionListener)

addItemListener

public void addItemListener(java.awt.event.ItemListener listener)
Adds an ItemListener to listen for ForwardedItemEvents on the MenuBar. ItemEvents sent out are a sub-class of ItemEvent, com.sas.visuals.ForwardedItemEvent. The events are sent whenever an ItemSelectable JMenuItem component sends out an ItemEvent.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
listener - the ItemListener to send the ItemEvents to.
See Also:
ItemEvent, ItemListener, removeItemListener(java.awt.event.ItemListener)

removeItemListener

public void removeItemListener(java.awt.event.ItemListener listener)
Removes an ItemListener from the list of listeners to be notified of ForwardedItemEvents.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
listener - the ItemListener to stop sending the ItemEvents to.
See Also:
ItemEvent, ItemListener, addItemListener(java.awt.event.ItemListener)

addForwardedItemListener

public void addForwardedItemListener(ForwardedItemListener listener)
Adds a ForwardedItemListener to listen for ForwardedItemEvents on the BaseButton The events are sent whenever an ItemSelectable JMenuItem component sends out an ForwardedItemEvent.

Specified by:
addForwardedItemListener in interface ForwardedItemSource
Parameters:
listener - the ForwardedItemListener to send the ItemEvents to.
See Also:
ForwardedItemEvent, ForwardedItemListener, removeForwardedItemListener(com.sas.visuals.ForwardedItemListener)

removeForwardedItemListener

public void removeForwardedItemListener(ForwardedItemListener listener)
Removes a ForwardedItemListener from the list of listeners to be notified of an ForwardedItemEvent.

Specified by:
removeForwardedItemListener in interface ForwardedItemSource
Parameters:
listener - the ForwardedItemListener to stop sending the ForwardedItemEvents to.
See Also:
ForwardedItemEvent, ForwardedItemListener, addForwardedItemListener(com.sas.visuals.ForwardedItemListener)

processForwardedActionEvent

protected void processForwardedActionEvent(ForwardedActionEvent e)
Process ForwardedActionEvents sent from the MenuBar to its ForwardedActionListeners.

Parameters:
e - the ForwardedActionEvent that needs to be processed

processItemEvent

protected void processItemEvent(java.awt.event.ItemEvent e)
Process ItemEvents sent from the MenuBar to its ItemListeners.

Parameters:
e - the ItemEvent that needs to be processed

processForwardedItemEvent

protected void processForwardedItemEvent(ForwardedItemEvent e)
Process ForwardedItemEvents sent from the MenuBar to its ForwardedItemListeners.

Parameters:
e - the ForwardedItemEvent that needs to be processed

getMenuItems

public javax.swing.JMenuItem[] getMenuItems(java.lang.String cmdStr)
Get the JMenuItems that have the specified actionCommand String.

Parameters:
cmdStr - the actionCommand String of the JMenuItems to return.
Returns:
an array of JMenuItems containing the JMenuItems that use the specified actionCommand String, or null if no JMenuItems are found with the actionCommand String.

setMenuItemsEnabled

public void setMenuItemsEnabled(java.lang.String cmd,
                                boolean enabled)
Sets the JMenuItems with the specified actionCommand to the given enabled state.

Parameters:
cmd - the actionCommand of the JMenuItems to find
enabled - the new enabled state of the JMenuItems found

parseMenuCommands

protected java.util.Enumeration parseMenuCommands(javax.swing.JMenu currentMenu,
                                                  java.lang.String cmdStr)
Parses a JMenu to find any JMenuItems that use the specified actionCommand String.

Parameters:
currentMenu - the JMenu to parse for JMenuItems with cmdStr for their actionCommand String.
cmdStr - the actionCommand String of the JMenuItems to return or null to return all JMenuItems.
Returns:
an Enumeration of the JMenuItems with the specified actionCommand String on the given JMenu.

updateJMenuItems

public void updateJMenuItems()
Parses all of the current JMenuItems and add the MenuBar as a listener to any events that they send out.


parseMenu

protected void parseMenu(javax.swing.JMenu currentMenu,
                         boolean addListeners)
Parses the JMenu to add or remove the MenuBar as a listener to any events sent out by JMenuItems on the given JMenu.

Parameters:
currentMenu - the JMenu to add or remove the MenuBar as a listener to all of its JMenuItems.
addListeners - if true, add the MenuBar as a listener to the JMenuItems on this JMenu, when false, remove the MenuBar as a listener to the JMenuItems on this JMenu.

removeListeners

public void removeListeners(javax.swing.JMenuItem menuItem,
                            boolean parseMenu)
Removes event listeners from the given JMenuItem. Also remove listeners from all of its child JMenuItems if it is a JMenu instance and parseMenu is true.

Parameters:
menuItem - the JMenuItem to remove the MenuBar as a listener.
parseMenu - if true and the menuItem is a JMenu instance, remove the MenuBar as a listener from all sub-JMenuItems

addListeners

public void addListeners(javax.swing.JMenuItem menuItem,
                         boolean parseMenu)
Adds event listeners needed to the given JMenuItem. Also add listeners to all of its child JMenuItems if it is a JMenu instance and parseMenu is true.

Parameters:
menuItem - the JMenuItem to add the MenuBar as a listener.
parseMenu - if true and the menuItem is a JMenu instance, add the MenuBar as a listener to all sub-JMenuItems

supportsListenerInterface

public boolean supportsListenerInterface(java.lang.Class listenerInterface)
Indicates whether the listenerInterface class passed in is a ForwardedActionListener .

Specified by:
supportsListenerInterface in interface MultipleValueEventSourceInterface
Parameters:
listenerInterface - the class to be tested
Returns:
true if listenerInterface is a ForwardedActionListener.

getEventMethod

public java.lang.reflect.Method getEventMethod(java.lang.reflect.Method lMethod)
Gets the event method.

Specified by:
getEventMethod in interface MultipleValueEventSourceInterface
Parameters:
IMethod - Method object to get the event method from
Returns:
a Method object if exists else returns null

getEventValues

public java.lang.String[] getEventValues(java.lang.reflect.Method lMethod)
Gets a string array of event values.

Specified by:
getEventValues in interface MultipleValueEventSourceInterface
Parameters:
IMethod - Method object to get the event values from
Returns:
a string array of event values

parseCommands

protected java.util.Enumeration parseCommands(javax.swing.JMenu currentMenu)
Parses the JMenu to get and add action commands to an OrderedCollection, and returns enumeration of the action commands

Parameters:
currentMenu - the JMenu to get and add action commands to the ordered collection
Returns:
an enumeration of the action commands from the JMenu.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.