June 2017
Beginner
1296 pages
69h 23m
English
... 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 223.0,204.0, 233.0,246.0, 205.0,222.0, 177.0,246.0, 187.0,204.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(255),
29 random.nextInt(255), random.nextInt(Read now
Unlock full access