|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.freehep.swing.popup.GlobalMouseListener
This class is designed to work around a deficiency in Swing's mouse handling. It enables a listener to be applied to a component so that all mouse events in that component, or any of its subcomponents will be reported. This is useful for example in creating Popup menus for complex graphical objects (such as plots).
There is no easy way to implement this functionality in Swing, so this class works by recursively adding mouse listeners to all components in the heirarchy. It also adds a ComponentListener so that it can add and remove listeners from items as they are added to the tree.
Warning: This class can have unexpected side effects in some rare cases. Normally swing will delegate mouse events to a component's parent if that component does not listen for mouse events itself. Since this class adds mouse listeners to all components, it can have the side effect of preventing this mouse event delegation. (In Java 1.4 it is possible to tell if a mouse listener already exists on a component, so maybe it would be possible to work around this limitation. Not clear how you would know if a mouse listener was subsequently added).
Constructor Summary | |
GlobalMouseListener(Component c)
Create a new GlobalMouseListener associated to a component |
Method Summary | |
void |
addMouseListener(MouseListener l)
Add a mouse listener. |
void |
removeMouseListener(MouseListener l)
Remove a mouse listener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GlobalMouseListener(Component c)
c
- The component on which to listen for mouse eventsMethod Detail |
public void addMouseListener(MouseListener l)
l
- The listener to addpublic void removeMouseListener(MouseListener l)
l
- The listener to remove
|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |