List of usage examples for javafx.scene.shape Circle setOnMousePressed
public final void setOnMousePressed(EventHandler<? super MouseEvent> value)
From source file:Main.java
private Circle createCircle(double x, double y, double r, Color color) { Circle circle = new Circle(x, y, r, color); circle.setCursor(Cursor.HAND); circle.setOnMousePressed((t) -> { orgSceneX = t.getSceneX();/*from w w w. ja va 2 s. c o m*/ orgSceneY = t.getSceneY(); Circle c = (Circle) (t.getSource()); c.toFront(); }); circle.setOnMouseDragged((t) -> { double offsetX = t.getSceneX() - orgSceneX; double offsetY = t.getSceneY() - orgSceneY; Circle c = (Circle) (t.getSource()); c.setCenterX(c.getCenterX() + offsetX); c.setCenterY(c.getCenterY() + offsetY); orgSceneX = t.getSceneX(); orgSceneY = t.getSceneY(); }); return circle; }