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 />

This time, you are going to call the .setBackground(Background value) method, with yet another Background<br />

class (object) constant, EMPTY. As Figure 4-8 illustrates, NetBeans will help you find the constant once you call the<br />

method off the StackPane object named root, using the following <strong>Java</strong> statement: root.setBackground(Background.<br />

EMPTY);. NetBeans provides a method selector drop-down and, once you select a method, an information dialog<br />

showing you the origin (superclass) of the method as well as what it does and an in-depth description. In this<br />

case, null (nothing), or zero Color fill, or zero Image set equates to TRANSPARENT. You are now ready to test your<br />

windowless (transparent) application version by using the run project work process.<br />

Figure 4-8. Call a .setBackground() method with a Background.EMPTY constant, off the StackPane object named root<br />

As you can see in Figure 4-9, you have now achieved your objective, and just the Button object is visible on the<br />

desktop. I pulled the top of NetBeans IDE 8.0 down a bit so that you can see how great this works and still see the<br />

three lines of <strong>Java</strong> code that you added to achieve this end result. Using 2D, 3D, and alpha channels, some crazy-cool<br />

applications can be created via this StageStyle.TRANSPARENT capability, so I thought I would show it to you early on<br />

in the book and get some <strong>Java</strong>FX application <strong>Java</strong> coding experience into this <strong>Java</strong>FX overview chapter.<br />

94<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!