|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MouseHandler
Handles certain types of mouse events and provides visual feedback. Mouse handlers
are intended to be registered with a MouseTool
.
The parent component, i.e., the component for which
the handler acts as a controller, is handed as an extra parameter to each method.
This eases sharing of handler objects between components and in most cases
should allow mouse handlers to be singleton objects.
Note that this component is not necessarily the source of the mouse events.
Handlers are linked in a chain of responsibility. To indicate that
a handler is responsible
for a given mouse gesture it should consume the mouse pressed event
at the end of the methods doMousePressed(javax.swing.JComponent, java.awt.event.MouseEvent)
,
doMouseClicked(javax.swing.JComponent, java.awt.event.MouseEvent)
and doPopup(javax.swing.JComponent, java.awt.event.MouseEvent)
.
The mouse gesture ends with the subsequent release of the mouse button.
Note that to be able to distinguish between a 'mouse clicked' and a 'mouse down'
the method doMousePressed(javax.swing.JComponent, java.awt.event.MouseEvent)
is only invoked as soon as the mouse is first
dragged.
Field Summary | |
---|---|
static MouseHandler |
NULL_MOUSE_HANDLER
Mouse handler that does not do anything. |
Method Summary | |
---|---|
boolean |
canHandle(javax.swing.JComponent parent)
Check whether this handler can work on the given component. |
void |
doMouseClicked(javax.swing.JComponent parent,
java.awt.event.MouseEvent mouseEvent)
Invoked when the mouse was clicked, i.e. |
void |
doMouseDragged(javax.swing.JComponent parent,
java.awt.event.MouseEvent mouseEvent,
java.awt.event.MouseEvent previousEvent,
java.awt.event.MouseEvent pressedEvent)
Invoked when the mouse pointer was dragged, i.e., moved while the button is down. |
void |
doMousePressed(javax.swing.JComponent parent,
java.awt.event.MouseEvent mouseEvent)
Invoked when the mouse was pressed down and then dragged for the first time. |
void |
doMouseReleased(javax.swing.JComponent parent,
java.awt.event.MouseEvent mouseEvent,
java.awt.event.MouseEvent pressedEvent)
Invoked when the mouse pointer was released after it was dragged. |
void |
doPopup(javax.swing.JComponent parent,
java.awt.event.MouseEvent mouseEvent)
Invoked when a popup gesture was invoked and the mouse did not actually move while the button was down. |
void |
paintDragging(javax.swing.JComponent parent,
java.awt.Graphics g,
java.awt.event.MouseEvent mouseEvent,
java.awt.event.MouseEvent previousEvent,
java.awt.event.MouseEvent pressedEvent)
Paint visual feedback while dragging the mouse. |
Field Detail |
---|
static final MouseHandler NULL_MOUSE_HANDLER
Method Detail |
---|
void doMouseClicked(javax.swing.JComponent parent, java.awt.event.MouseEvent mouseEvent)
doPopup(javax.swing.JComponent, java.awt.event.MouseEvent)
is invoked instead.
Handlers should consume the event if they take responsibility for this mouse gesture.
parent
- Component for which this handler acts as a controllermouseEvent
- Corresponding mouse eventvoid doPopup(javax.swing.JComponent parent, java.awt.event.MouseEvent mouseEvent)
Handlers should consume the event if they take responsibility for this mouse gesture.
parent
- Component for which this handler acts as a controllermouseEvent
- Corresponding mouse eventvoid doMousePressed(javax.swing.JComponent parent, java.awt.event.MouseEvent mouseEvent)
Handlers should consume the event if they take responsibility for the mouse gesture started by this press (and ending with the subsequent release of the button).
parent
- Component for which this handler acts as a controllermouseEvent
- Corresponding mouse eventvoid doMouseDragged(javax.swing.JComponent parent, java.awt.event.MouseEvent mouseEvent, java.awt.event.MouseEvent previousEvent, java.awt.event.MouseEvent pressedEvent)
doMousePressed(javax.swing.JComponent, java.awt.event.MouseEvent)
event
was not consumed by this object.
parent
- Component for which this handler acts as a controllermouseEvent
- Corresponding mouse eventpressedEvent
- Mouse event that initiated this gesturepreviousEvent
- Pressed or dragged event before this event.void doMouseReleased(javax.swing.JComponent parent, java.awt.event.MouseEvent mouseEvent, java.awt.event.MouseEvent pressedEvent)
doMousePressed(javax.swing.JComponent, java.awt.event.MouseEvent)
event
was not consumed by this object.
parent
- Component for which this handler acts as a controllermouseEvent
- Corresponding mouse eventpressedEvent
- Mouse event that initiated this gesturevoid paintDragging(javax.swing.JComponent parent, java.awt.Graphics g, java.awt.event.MouseEvent mouseEvent, java.awt.event.MouseEvent previousEvent, java.awt.event.MouseEvent pressedEvent)
doMousePressed(javax.swing.JComponent, java.awt.event.MouseEvent)
event
was not consumed by this object.
parent
- Component for which this handler acts as a controllerpressedEvent
- Mouse event that initiated this gesturemouseEvent
- Mouse event corresponding to the last dragg
- Graphics context onto which the visual feedback should be drawnboolean canHandle(javax.swing.JComponent parent)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |