From the course: Learning JavaFX GUI Development

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Solution: Create a scene with random shapes and colors

Solution: Create a scene with random shapes and colors

From the course: Learning JavaFX GUI Development

Solution: Create a scene with random shapes and colors

(chime) - [Voiceover] I want to review the program that I created for this challenge. First, let me run it so you can see what happens. As you can see, my program is creating various size circles, some different rectangles, and some lines. Let's take a look at the code. On line 34, I create a group root node. On line 36, I create another group called Circles. I have a for loop set up that randomly generates the starting x-y position and the radius of the circle, and then I add the stroke type, the stroke color, and the stroke width. Let me scroll down a little bit. On line 48, I did the same thing with rectangles. Rectangles need a starting x-y, a width, and a height. And finally, on line 61, I have my lines. Lines need a starting x-y, and an ending x-y. Let me scroll down again. On line 75 is where I add each of my groups, circles, rectangles, and lines, onto the root node. Let's see what happens if I…

Contents