Java Reference
In-Depth Information
TextFlow flow = new TextFlow(java8Recipes2,
java8Recipes3, java8Recipes4, java8Recipes5);
root.getChildren().add(flow);
There were a lot of concepts introduced within this recipe. You will learn more
about FXML in a later recipe, or for more information you can see the online docu-
mentation at http://docs.oracle.com/javafx/2/get_started/
fxml_tutorial.htm . You an learn more about the TextFlow layout reading the
documentation at http://docs.oracle.com/javase/8/javafx/api/
javafx/scene/text/TextFlow.html .
14-4. Creating Shapes
Problem
You want to create shapes to be placed on the scene graph.
Solution
Use JavaFX's Arc , Circle , CubicCurve , Ellipse , Line , Path , Polygon ,
Polyline , QuadCurve , Rectangle , SVGPath , and Text classes in the
javafx.scene.shape.* package. The following code draws various complex
shapes. The first complex shape involves a cubic curve drawn in the shape of a sine
wave. The next shape, called the ice cream cone, uses the path class that contains path
elements ( javafx.scene.shape.PathElement) . The third shape is a Quadrat-
ic Bézier curve ( QuadCurve ) and it forms a smile. The final shape is a delectable
donut. You can create this donut shape by subtracting two ellipses (one smaller and one
larger):
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Chapter 14-4 Creating Shapes");
Group root = new Group();
Scene scene = new Scene(root, 306, 550, Color.WHITE);
Search WWH ::




Custom Search