... Two-Dimensional Shapes

Figure 22.4 shows the CSS for the BasicShapes app. In this CSS file, we define two CSS rules with ID selectors (#line1 and #line2) to style the app’s two Line objects. The remaining rules use type selectors, which apply to all objects of a given type. You specify a type selector by using the JavaFX class name.

Fig. 22.4

 1   /%*Fig.22.4: BasicShapes.css %*/
 2   /%*CSS that styles various two-dimensional shapes %*/
 3
 4   Line, Rectangle, Circle, Ellipse, Arc {
 5       -fx-stroke-width: 10;
 6   }
 7
 8   #line1 {
 9       -fx-stroke: red;
10   }
11
12   #line2 {
13       -fx-stroke: rgba(0%, 50%, 0%, 0.5);
14       -fx-stroke-line-cap: round;
15   }
16
17   Rectangle {
18      -fx-stroke: red;
19      -fx-arc-width: 50;
20      -fx-arc-height: 50;
21      -fx-fill: yellow;
22   }
23
24 Circle { ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.