CSC 502 Graded Homework 1

Write a JavaFX program that sets colors as selected by clicking on one of three buttons labeled red, white, and blue, or by the user typing the name of a color into a text field. The initial GUI of the program looks like this:

Now if the user types the name of a color into the text field and and types enter, the background color changes accordingly. This only need to work for recognized colors, and there a lot of colors that are recognized:

But the user can also select a button to choose a preselected color from one of red, white, and blue. For example, if the user clicks the button labeled white, the background color turns to white. Same thing occurs with red:

One way to do this is to nest some horizontal boxes in a vertical box and use the vertical box as the parent node for the scene graph. You can then change the background color of the vertical box in response to the appropriate user events. To change the background color of a node, you should set its CSS style. For example,

will set the background color to yellow. Same thing for whichever color you want. Use a string variable that you can set to different colors while keeping the same "-fx-background-color:" prefix. Then you only need to append the color to the prefix.

Due Date

Sunday night at the end of week 3.