Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 7 ■ IntroduCtIon to JavaFX 9: overvIew oF the JavaFX new MedIa engIne


As you can see in Figure 7-4, I clicked the initStyle(StageStyle style) option in the NetBeans 9 helper,
and this brings up a Javadoc window above the line of code you are crafting with documentation about the
method. You can use this as a way to learn what methods an object supports by typing the object name,
hitting the period key, and then selecting each method to see what it does.
As you can see in Figure 7-5, the Stage object is created using the .start(Stage primaryStage)
method call declaration and is set up (titled, styled, loaded with a scene, and then displayed) using the
.setTitle(), .initStyle(), .setScene(), and finally the .show() method calls inside of the .start() method
structure.
I’m going to leave a .setTitle() method call in the Java 9 code for now, but make a mental note that once
you get this windowless application treatment working, this title is part of the window’s chrome (titlebar UI
element). Once these are gone (including the titlebar), this setting of the title attribute will amount to being a
moot point.
If you were focusing on memory optimization at this point in the application development work
process, you would remove this .setTitle() method call because the title attribute would take up memory
space and wouldn’t even be seen because of your use of the StageStyle.TRANSPARENT constant for the
StageStyle (actually window style) attribute.
Inside of the .initStyle() method type, type the required StageStyle class (object) and a period to
bring up the next helper selector. This time it is a constant selector, as shown in Figure 7-5. Select the
TRANSPARENT option, read the Javadoc information on it, and then double-click it to complete the code
statement, which should look like the following:


primaryStage.initStyle(StageStyle.TRANSPARENT); // Insert StageStyle Class TRANSPARENT
Constant


Figure 7-4. Call an .initStyle() method off of the primaryStage Stage object, using dot notation to invoke a
helper menu

Free download pdf