com.objectwave.viewUtility
Class PopupMenu

java.lang.Object
  |
  +--java.awt.event.MouseAdapter
        |
        +--com.objectwave.viewUtility.PopupMenu
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, javax.swing.event.PopupMenuListener

public class PopupMenu
extends java.awt.event.MouseAdapter
implements javax.swing.event.PopupMenuListener

Encapsulate all of the support necessary to support popup menus. Use like: PopupMenu menu = new PopupMenu(); for(int i = 0; i < .length; ++i) { menu.add(action[i]); } myFrame.addMouseListener(menu);

Version:
$Id: PopupMenu.java,v 2.1 2002/07/31 15:55:23 dave_hoag Exp $

Nested Class Summary
protected  class PopupMenu.ActionChangedListener
          Expanded from the default of JPopupMenu to include updates the icon.
static class PopupMenu.Test
           
 
Field Summary
protected  java.awt.Point popupPoint
           
protected  javax.swing.JPopupMenu selectionPopup
           
 
Constructor Summary
PopupMenu()
           
 
Method Summary
 javax.swing.JMenuItem add(javax.swing.Action act)
          Append a new menuitem to the end of the menu which dispatches the specified Action object.
 void addPopupMenuListener(javax.swing.event.PopupMenuListener l)
          Add a PopupMenu listener
 void addSeparator()
          Delegate to the real popup menu.
 javax.swing.JMenuItem addTransientMenuItem(javax.swing.Action act)
          Append a new menuitem to the end of the menu which dispatches the specified Action object.
 void addTransientSeparator()
          Delegate to the real popup menu.
 void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Add a VetoableListener to the listener list.
protected  java.beans.PropertyChangeListener createActionChangeListener(javax.swing.JMenuItem b)
           
 java.awt.Component getComponent()
          The component in which the mouse was righclicked.
 java.awt.Component getPopupComponent()
          In the event we have nested components, this will get the deepest component at that point.
 java.awt.Point getPopupPoint()
          The point within the 'component' that mouse was righclicked.
 boolean isEventSource(javax.swing.event.PopupMenuEvent evt)
          Since this class is hiding the popup menu, the PopupMenuEvents will not contain this class as the source.
 void mousePressed(java.awt.event.MouseEvent e)
           
protected  void popupClosed()
           
 void popupMenuCanceled(javax.swing.event.PopupMenuEvent e)
           
 void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)
           
 void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent e)
           
 void removePopupMenuListener(javax.swing.event.PopupMenuListener l)
          Remove a PopupMenu listener
 void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Remove a VetoableChangeListener from the listener list.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseEntered, mouseExited, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectionPopup

protected javax.swing.JPopupMenu selectionPopup

popupPoint

protected java.awt.Point popupPoint
Constructor Detail

PopupMenu

public PopupMenu()
Method Detail

isEventSource

public boolean isEventSource(javax.swing.event.PopupMenuEvent evt)
Since this class is hiding the popup menu, the PopupMenuEvents will not contain this class as the source. This method enables the user of this class to determine if this instance is the source of the PopupMenuEvent.

Parameters:
evt - The real popup menu event.

addPopupMenuListener

public void addPopupMenuListener(javax.swing.event.PopupMenuListener l)
Add a PopupMenu listener

Parameters:
l - The Listener to add.

removePopupMenuListener

public void removePopupMenuListener(javax.swing.event.PopupMenuListener l)
Remove a PopupMenu listener

Parameters:
l - The listener to remove.

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Add a VetoableListener to the listener list. Allow listeners to Veto the display of the popup. A PropertyChangeEvent with the property name of 'showPopup' will be generated. The newValue of the event will be the deepest component at that popup point.

Parameters:
listener - The VetoableChangeListener to be added

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Remove a VetoableChangeListener from the listener list.

Parameters:
listener - The VetoableChangeListener to be removed

popupMenuWillBecomeVisible

public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent e)
Specified by:
popupMenuWillBecomeVisible in interface javax.swing.event.PopupMenuListener

popupMenuCanceled

public void popupMenuCanceled(javax.swing.event.PopupMenuEvent e)
Specified by:
popupMenuCanceled in interface javax.swing.event.PopupMenuListener

popupMenuWillBecomeInvisible

public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)
Specified by:
popupMenuWillBecomeInvisible in interface javax.swing.event.PopupMenuListener

getPopupPoint

public java.awt.Point getPopupPoint()
The point within the 'component' that mouse was righclicked.


popupClosed

protected void popupClosed()

getComponent

public java.awt.Component getComponent()
The component in which the mouse was righclicked.


getPopupComponent

public java.awt.Component getPopupComponent()
In the event we have nested components, this will get the deepest component at that point.

Returns:
java.awt.Component Deepest component at that point.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class java.awt.event.MouseAdapter
Parameters:
e - MouseEvent The event

addSeparator

public void addSeparator()
Delegate to the real popup menu.


addTransientSeparator

public void addTransientSeparator()
Delegate to the real popup menu.


addTransientMenuItem

public javax.swing.JMenuItem addTransientMenuItem(javax.swing.Action act)
Append a new menuitem to the end of the menu which dispatches the specified Action object. After the menu is closed, this menu item will be removed from the list of items. Usefull for context specific menus.

Parameters:
act - The Action object contains all of the information to create both the Menu label and the action to take upon selection.
See Also:
Action

add

public javax.swing.JMenuItem add(javax.swing.Action act)
Append a new menuitem to the end of the menu which dispatches the specified Action object.

Parameters:
act - The Action object contains all of the information to create both the Menu label and the action to take upon selection.
See Also:
Action

createActionChangeListener

protected java.beans.PropertyChangeListener createActionChangeListener(javax.swing.JMenuItem b)