28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4 ■ An Introduction to <strong>Java</strong>FX 8: Exploring the Capabilities of the <strong>Java</strong> 8 Multimedia Engine<br />

Next, use the Run icon (or Run menu), and run the application. As Figure 4-5 illustrates, what you are trying to<br />

achieve did not work: the window chrome elements are gone, and the transparency value is not evident.<br />

Figure 4-5. Run the project to see if the Stage object is transparent; clearly, something is set to White<br />

There must be something else in the processing pipeline that is not yet defining its background using the<br />

transparency value. Transparency is defined using a hexadecimal value of #00000000, which signifies that all<br />

AARRGGBB (alpha channel, red, green, blue) color and opacity values are turned off. You will need to start thinking<br />

about the <strong>Java</strong>FX components of your application as layers (currently, these are stage-scene-stackPane-button).<br />

You will be learning about digital imaging concepts such as color depth, alpha channels, layers, blending, and all the<br />

technical information that relates to processing pixels in a 2D plane as the book progresses.<br />

The next thing you should try to set to this transparent value is the next level down in the <strong>Java</strong>FX Scene Graph<br />

hierarchy from the stage, which contains the Scene Graph itself. The next most top-level component, as discussed<br />

previously, is the Scene object, which also has a background color value parameter or attribute.<br />

Like the Stage class (object), the Scene class (object) does not have a style constant of TRANSPARENT, so you will<br />

have to approach setting the Scene object’s background to a transparency value in a different way, using a different<br />

method and constant. One thing you should know is that everything in <strong>Java</strong>FX that writes itself to the screen will in<br />

some way support transparency to allow multiple-layer compositing in <strong>Java</strong>FX applications.<br />

If you read the Scene class documentation, you will notice that there is a method, .setFill(Color value), that<br />

takes a Color (class or object) value, so let’s try that next. As Figure 4-6 shows, I called the .setFill() off the Scene object<br />

named scene, using a scene.setFill(Color.TRANSPARENT); statement, which NetBeans helps me construct!<br />

www.it-ebooks.info<br />

91

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!