The action is perform when mouse moved in to the object defined in group
, coordinates are printed out at which the mouse drops. I found this could be achieved by these two methods:
// method 1:
group.setOnMouseMoved(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
System.out.printf("coordinate X: %.2f, coordinate Y: %.2f\n",event.getX(),event.getY());
}
});
// method 2:
group.onMouseMovedProperty().set(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
System.out.printf("coordinate X: %.2f, coordinate Y: %.2f\n",event.getX(),event.getY());
}
});
Both gave me the expected results. The syntax looks almost the same, I just wondered if there's any difference between those two? When do we use one from the other?