Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 23 ■ Completing the gameplay Code and player proofing your event handling


Use Run ➤ Project to view the final Button UI element styling. As you can see in Figure 23-23, it looks
great!


Next, add a .setOnAction() event handling construct to againButton so that when the Button is
clicked, you can turn off the Q&A and Scoring (StackPane) panels and reset the buttonClick, squareClick,
and spinnerClick variables to false (off ) so that the 3D spinner, game board squares, and answer Button UI
elements can be used. The initial Java code for these visibility and click-proofing reset statements is shown in
blue in Figure 23-24.


Figure 23-24. Add the .setOnAction() method call to againButton; start adding mouse click and visibility
event handling


Figure 23-23. Use a Run ➤ Project work process to test the againButton to see if it is located, sized, and
colored properly

Free download pdf