edu.southern.computing.oopj
Class ContextMenu

java.lang.Object
  extended by edu.southern.computing.oopj.ContextMenu
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public abstract class ContextMenu
extends java.lang.Object
implements java.awt.event.ActionListener

Context-sensitive popup menu that can be added to viewports and graphical objects.


Constructor Summary
ContextMenu(java.lang.String... items)
          Creates a new context menu.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ev)
          Subclasses ordinarily do not override this method.
 void attachMenu(javax.swing.JPanel comp)
          Associates this menu with a viewport or graphical object.
abstract  void handler(java.lang.String item)
          Subclasses using a popup menu should override this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextMenu

public ContextMenu(java.lang.String... items)
Creates a new context menu.

Parameters:
items - a comma separated list of strings to appear as menu items in the context sensitive popup menu.
Method Detail

attachMenu

public void attachMenu(javax.swing.JPanel comp)
Associates this menu with a viewport or graphical object.

Parameters:
comp - the viewport or graphical object to which this menu is bound.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ev)
Subclasses ordinarily do not override this method.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

handler

public abstract void handler(java.lang.String item)
Subclasses using a popup menu should override this method. Generally the program will add a conditional statement to select actions based on the menu item chosen by the user. It is the programmer's responsibility to ensure that strings checked in the conditional logic correspond to actual items the menu.

Parameters:
item - the menu item chosen by the user.