Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 21 ■ Questions and answers: Finishing the setup Methods and digital audio

Right-click in the selection set, shown in blue in Figure 21-1, and select a Cut option to remove the
statements from the createBoardGameNodes() method. This will then place them into your OS clipboard to
later be pasted into the new createUInodes() method, which we are about to create.
Inside your start() method, add a line of code after createBoardGameNodes(); and create a method
call to the createUInodes() method, which does not yet exist. Use an Alt+Enter keystroke combination to
have NetBeans create this method for you, as shown in yellow and light blue in Figure 21-2 after it has been
created.
NetBeans 9 will create this new method and placeholder error code, which we will select (be sure to
select only the error code statement, not the method body) and then use Paste to replace the error code
statement with the 34 Java statements that create our uiLayout SceneGraph Node hierarchy, which is
currently in the OS clipboard. I also selected the entire method body (this must be done after the bootstrap
error code has been replaced with your clipboard code) and cut and pasted it from the end of the class to
right after the createBoardGameNodes() method body. This keeps the 20 setupQSgameplay() method
bodies at the end of the class as we’ll be adding question (image) answers to these classes as part of the
gameplay production work that must be accomplished in the chapter.


The two new methods are shown in Figure 21-3 and are simply a reconfiguration of the previous
method’s Java code. We’re simply putting a little code organization in place here before creating a
createQAnodes() method.


Figure 21-2. Create the createUInodes() method call after the createBoardGameNodes() method call and use
Alt+Enter

Free download pdf