Class awtExt.MenuItem
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class awtExt.MenuItem

java.lang.Object
   |
   +----java.awt.MenuComponent
           |
           +----java.awt.MenuItem
                   |
                   +----awtExt.MenuItem

public class MenuItem
extends MenuItem
Extension of standard awt MenuItem. Provides a callback mechanism for invoking a user defined method, when an ACTION_EVENT occurs within this awtExt component. The called back method and target object must have a specific signature. This allows you to separate your application functionality from the GUI. i.e, no need to subclass the MenuItem in order to invoke your user defined code.

NOTE: This component does NOT  use the general EventDispatch
mechanism, as the only event of interest is the ACTION_EVENT.
See Also:
Callback, MenuItem

Constructor Index

 o MenuItem(String)
Constructor.
 o MenuItem(String, methodRef)
Constructor.
 o MenuItem(String, Object, String)
Constructor.

Method Index

 o addActionCallback(methodRef)
Adds a user defined methodRef.
 o handleEvent(Event)
Handles the event.
 o postEvent(Event)
Posts the specified event to the menu item.

Constructors

 o MenuItem
  public MenuItem(String aLabel)
Constructor. Takes a string as a parameter, to be used as the label.
Parameters:
aLabel - label for the MenuItem
 o MenuItem
  public MenuItem(String aLabel,
                  methodRef mr)
Constructor.
Parameters:
aLabel - label for the MenuItem
mr - method reference to callbackable method. mr must have the target object set.
See Also:
setTarget
 o MenuItem
  public MenuItem(String aLabel,
                  Object target,
                  String method) throws InvalidMethodRefException
Constructor.
Parameters:
aLabel - label for the MenuItem
target - object which is target of the called back method
method - string representation of method to invoke on target object.
Throws: InvalidMethodRefException
If generation of callback fails

Methods

 o addActionCallback
  public void addActionCallback(methodRef aMethodRef)
Adds a user defined methodRef. This is invoked when a ACTION_EVENT occurs. The methodRef must be defined using the utility class awtExt.Callback
Parameters:
aMethodRef - ACTION_EVENT event handling method.
See Also:
Callback, methodRef
 o postEvent
  public final boolean postEvent(Event evt)
Posts the specified event to the menu item. The event will propagate to its menu container, if it's not handled in here, or if the CallbackInfo.processed is false.
Parameters:
evt - the event which is to take place
Overrides:
postEvent in class MenuComponent
See Also:
Callback
 o handleEvent
  public final boolean handleEvent(Event evt)
Handles the event. Invokes user defined method, if there is one. Returns CallbackInfo.processed to control event propagation
Parameters:
evt - the event which is to take place
See Also:
CallbackInfo, processed

All Packages  Class Hierarchy  This Package  Previous  Next  Index