Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 9 ■ JavaFX 9 User InterFaCe DesIgn: the Front enD For Java 9 game DesIgn


As you can see in Figure 9-20, I have added the logo and fixed the text paragraph (left) alignment,
removing that space after the\n, which is counterintuitive because it leaves\ncopyrights and there is no
escape ncopyrights. You as a Java programmer would need to know in this situation that the compiler will
look at the escape () character, and only one letter thereafter (in this case n or newline), and then continue
parsing characters as part of your text content.


The logo has been added to the compositing layer container (StackPane), resized (scaled) to fit next to
the Button bank, and moved up (translated) to center with your Button bank. This all looks well-balanced
and professional; it uses very few nodes in the SceneGraph and very few objects in system memory, so it’s
optimized.
Since we’re not using the transparency (trick) that I showed you back in Chapter 7 for this UI, let’s
replace the OS chrome by reverting to the default DECORATED StageStyle class constant, which I could do
by removing the primaryStage.initStyle() method call. Instead, I will leave that Java statement in place and
change the TRANSPARENT constant use to a DECORATION constant use in case we want to decorate the Stage
object differently in the future. This is done by changing this line of code, shown in line 46 in Figure 9-21, to the
following Java code:


primaryStage.initStyle(StageStyle.DECORATED);


Figure 9-20. Run the project and check the result of adding ImageView object to the splash screen compositing
pipeline

Free download pdf