Package org.geotools.swing
Class MouseDragBox
Object
MouseAdapter
MouseInputAdapter
MouseDragBox
- All Implemented Interfaces:
MouseListener,MouseMotionListener,MouseWheelListener,EventListener,MouseInputListener
Draws a box on the parent component (e.g. JMapPane) as the mouse is dragged.
- Since:
- 8.0
- Author:
- Michael Bedward
-
Constructor Summary
ConstructorsConstructorDescriptionMouseDragBox(JComponent component) Creates a new instance to work with the given component. -
Method Summary
Modifier and TypeMethodDescriptionvoidIf the box is enabled, draws the box with the diagonal running from the start position to the current mouse position.voidIf the box is enabled, records the start position for subsequent drawing as the mouse is dragged.voidIf the box is enabled, removes the final box.voidsetEnabled(boolean state) Enables or disables the drag box.Methods inherited from class MouseAdapter
mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseWheelMovedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MouseListener
mouseClicked, mouseEntered, mouseExitedMethods inherited from interface MouseMotionListener
mouseMoved
-
Constructor Details
-
MouseDragBox
Creates a new instance to work with the given component.- Parameters:
component- the component on which the box will be drawn
-
-
Method Details
-
setEnabled
public void setEnabled(boolean state) Enables or disables the drag box. When enabled, the box is drawn on mouse dragging.- Parameters:
state-trueto enable;falseto disable
-
mousePressed
If the box is enabled, records the start position for subsequent drawing as the mouse is dragged.- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classMouseAdapter- Parameters:
ev- input mouse event
-
mouseDragged
If the box is enabled, draws the box with the diagonal running from the start position to the current mouse position.- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin classMouseAdapter- Parameters:
ev- input mouse event
-
mouseReleased
If the box is enabled, removes the final box.- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classMouseAdapter- Parameters:
ev- the input mouse event
-