Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 8 ■ JavaFX 9 SCene Graph hierarChy: a Foundation For Java 9 Game deSiGn


and use the Alt+Enter key combination to have NetBeans 9 create this method infrastructure for you at
the bottom of the class. Also, be sure that you add the root = new Group(); object instantiation since you
renamed the StackPane object uiLayout (as shown in Figure 8-5).


Cut and paste your object instantiation and configuration code currently in the .start() method (you will
be adding to this later) into the createBoardGameNodes() method to replace the “Not Supported Yet” line of
error code in the bootstrap method, as shown (selected) in Figure 8-8. The new .createBoardGameNodes()
method should look like the following once you are finished with this Java 9 code reconfiguration operation:


private void createBoardGameNodes() {
root = new Group();
scene = new Scene(root, 640, 400);
scene.setFill(Color.TRANSPARENT);
gameButton = new Button();
gameButton.setText("Start Game");
uiLayout = new StackPane();
uiLayout.setBackground(Background.EMPTY);
uiLayout.getChildren().add(gameButton);
}


Figure 8-7. Add a createBoardGameNodes() method call at the top of the .start() method and add root = new
Group()

Free download pdf