... javafx.scene.transform.Transform;
 9
10   public class DrawStarsController {
11      @FXML private Pane pane;
12      private static final SecureRandom random = new SecureRandom();
13
14      public void initialize() {
15         // points that define a five-pointed star shape                    
16         Double[] points = {205.0,150.0, 217.0,186.0, 259.0,186.0,          
17            223.0,204.0, 233.0,246.0, 205.0,222.0, 177.0,246.0, 187.0,204.0,
18            151.0,186.0, 193.0,186.0};                                      
19
20         // create 18 stars
21         for (int count = 0; count < 18; ++count) {
22            // create a new Polygon and copy existing points into it
23            Polygon newStar = new Polygon();   
24            newStar.getPoints().addAll(points);
25
26            // create random Color and set as newStar's fill
27            newStar.setStroke(Color.GREY);                
28            newStar.setFill(Color.rgb(random.nextInt(

Get Java How To Program, Late Objects, 11th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.