Java Reference
In-Depth Information
( Path ). These LineTo objects are instances of path element
( javafx.scene.shape.PathElement ), as discussed in Recipe 15-5. The fol-
lowing code is an event handler responsible for mouse-drag events:
// dragging creates lineTos added to the path
scene.onMouseDraggedProperty().set((EventHandler<MouseEvent>)
(MouseEvent event) -> {
onePath.getElements().add(new
LineTo(event.getX(), event.getY()));
});
Finally, create an event handler to listen to a mouse-release event. When a user re-
leases the mouse, the path's stroke is set to zero to appear as if it has removed. Then
you reset the path transition by stopping it and playing it from the start. The following
code is an event handler responsible for a mouse-release event:
// end the path when mouse released event
scene.onMouseReleasedProperty().set((EventHandler<MouseEvent>)
(MouseEvent event) -> {
onePath.setStrokeWidth(0);
if (onePath.getElements().size() > 1) {
pathTransition.stop();
pathTransition.playFromStart();
}
});
15-4. Manipulating Layout via Grids
Problem
You want to create a nice-looking form-based user interface using a grid type layout.
Solution
Search WWH ::




Custom Search