Note that the JavaFX developers decided to not introduce an extra class for strokes; all corresponding methods belong to the Shape class instead:
shape.setStroke(Color.BLACK);shape.setStrokeWidth(10);shape.setStrokeType(StrokeType.CENTERED);
The first two are pretty self-explanatory—color and width. Next up is a stroke type that controls positioning relative to shape's edge. See the following image and corresponding sample:
// chapter2/strokes/StrokeTypesDemo.javahbox.getChildren().add(new VBox(5, new Text("NONE"), new Rectangle(50,50, Color.LIGHTGRAY)));for (StrokeType type : StrokeType.values()) { Rectangle rect = new Rectangle(50,50, Color.LIGHTGRAY); rect.setStrokeType(type); rect.setStroke(Color.BLACK); rect.setStrokeWidth(10); ...