How-To's > How do I enable users to drag and drop objects?
Use the onMouseDragged event to enable users to drag an object within a scene's boundaries.
For a simple code snippet and more details about the onMouseDragged event, see How do I create a response to a mouse event?
Example code for the objects to be dragged and the onMouseDragged event is provided in the following documents:
- Building GUI Applications With JavaFX: Lesson 8: Bringing Interactivity to GUI Elements
The section "Handling the Drag Event" provides information about dragging objects with the mouse. - Getting Started With JavaFX Technology
The page "Creating Your First JavaFX Application" demonstrates the use of theonMousedraggedevent.
API Documentation
- onMouseDragged variable of javafx.scene.Node
Last Updated: November 2009
[Return to How-To's Home]
Do you have comments about this article? We welcome your participation in our community. Please keep your comments civil and on point. You may optionally provide your email address to be notified of repliesyour information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.