A MouseEvent is fired whenever a mouse button is pressed, released,
clicked, moved, or dragged on a node or a scene.
The MouseEvent object captures the event, such as the location (the x-
and y-coordinates) of the mouse, the number of clicks associated with it
or which mouse button was pressed, etc.
For example the following line checks whether the primary (left)
mouse button was pressed.
if(event.getButton() == MouseButton.PRIMARY)
{
//……
}
MouseEvent
User Action Source Event Type Registration Method
Mouse pressed
Mouse released
Mouse clicked
Mouse entered
Mouse exited
Mouse moved
Mouse dragged
Node,
Scene
MouseEvent setOnMousePressed(EventHandler<MouseEvent>)
setOnMouseReleased(EventHandler<MouseEvent>)
setOnMouseClicked(EventHandler<MouseEvent>)
setOnMouseEntered(EventHandler<MouseEvent>)
setOnMouseExited(EventHandler<MouseEvent>)
setOnMouseMoved(EventHandler<MouseEvent>)
setOnMouseDragged(EventHandler<MouseEvent>)
The following table list the registration method for
different mouse actions.
Handle Mouse Press Event (see DotDemoOne.java and DotsPaneDemo.java)
Handle Mouse Press-Drag-Release Event (see MousePressDragReleaseDemo.java
and CirclePane.java)
Powered by TCPDF (www.tcpdf.org)