Package ca.corbett.extras
Class RedispatchingMouseAdapter
java.lang.Object
ca.corbett.extras.RedispatchingMouseAdapter
- All Implemented Interfaces:
MouseListener,MouseMotionListener,MouseWheelListener,EventListener
public class RedispatchingMouseAdapter
extends Object
implements MouseListener, MouseWheelListener, MouseMotionListener
Sometimes you want mouse events that arrive on a child component to bubble up to the
containing component to be processed there. For example, you have a JLabel sitting
inside a JPanel, but when a mouse event happens on the JLabel, you want the JPanel
to receive it instead. So, we need a way to propagate the mouse events up to
the parent. I found this solution on StackOverflow and it seems to work really well.
All credit goes to user Wojciech Wirzbicki and his
answer from 2015.
- Since:
- 2017-11-12
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidvoidvoidvoid
-
Constructor Details
-
RedispatchingMouseAdapter
public RedispatchingMouseAdapter()
-
-
Method Details
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseWheelMoved
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-