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

Set the alignment of the VBox to the Pos.TOP_RIGHT constant from the Pos helper class using the
.setAlignment() method by using the following Java statement, shown under construction in Figure 8-10:


uiContainer.setAlignment(Pos.TOP_RIGHT); // Set VBox Alignment to TOP_RIGHT via Pos helper
class


Use the Alt+Enter keystroke combination to eliminate the wavy red error underlining, and be sure to
select the correct solution to the problem, which in this case is an Add import for javafx.geometry.Pos
option, which is listed first (most likely to be the correct solution) and which is the solution that allows a Pos
class to be used in your code.
In the next step, we will create the uiPadding Insets object using the uiPadding = new
Insets(0,0,10,10); Java instantiation statement, shown in line 58 in Figure 8-11. Finally, we will
“wire up” the uiPadding Insets object to the uiContainer VBox object by using the uiContainer.
setPadding(uiPadding); method call. This connection is shown in yellow in Figure 8-11 and shows a
connection between the Insets declaration, instantiation, and implementation.


Figure 8-10. Inside of the .setAlignment() method parameter area, type Pos.TOP_RIGHT and hit Alt+Enter to
import

Free download pdf