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


Next use the Run icon (or the Run menu) and run the application. As you can see in Figure 7-6, what we
are trying to achieve did not work, and the Window chrome elements are gone, but the transparency value is
not evident.


As you can see, there is an off-white color value (used in iTV set applications, as some iTV sets don’t
support a 255,255,255 White) that is evident against the full 255,255,255 white that NetBeans 9 uses for its
code editor pane.
There must be something else in your processing pipeline that is not yet defining your Stage’s
background using the transparency value. Transparency is defined using the hexadecimal value of
0x00000000, which signifies all AARRGGBB (Alpha, Red, Green Blue) transparency and color values being
turned off. You need to start thinking about the JavaFX components within your application as being layers
(currently these are Stage, Scene, StackPane, Button).
You learned about digital imaging concepts, such as color depth, alpha channels, layers, blending,
dithering, and all of that fun technical information that relates to processing pixels in a 2D plane during
Chapter 2 of this book.
The next thing that we should try to set to this transparent value is the next level down in your JavaFX
Scene Graph hierarchy from the Stage, which contains the Scene Graph itself. The next most top-level
component, as you’ve learned during this chapter, is the Scene object, which also has a background color
value parameter or attribute.
Therefore, the next step is to try to set that attribute to zero opacity and color using the hexadecimal
value of 0x00000000 or a Java 9 Color class constant that will accomplish this same exact objective.
Your Scene class (object) does not have the style constant of TRANSPARENT like the Stage class (object)
has, so you will have to approach setting the Scene object’s background to a transparency value in a different
way, using a different method and constant. One thing that you should realize is that everything in JavaFX
that writes itself to the screen will in some way or another support transparency. This allows multiple layer
compositing within JavaFX apps.


Figure 7-6. Run Project to see if the Stage object is transparent; clearly there is an object set to off-white
background color

Free download pdf