Game Development Reference
In-Depth Information
All Stage objects have a StageStyle attribute and a Modality attribute, which can
be set using constants. The stageStyle constants are StageStyle.DECORATED ,
StageStyle.UNDECORATED , StageStyle.TRANSPARENT , and
StageStyle.UTILITY . The Modality constants are Modality.NONE , Modal-
ity.APPLICATION_MODAL , and Modality.WINDOW_MODAL . In the next sec-
tion, I will show you how to do something really impressive using the StageStyle at-
tribute and the TRANSPARENT constant that will make your JavaFX applications
stand out from everyone else's in the marketplace.
The Popup class can be used to create custom pop-up notifications, and even cus-
tom game components, from scratch. Alternately, you can use the PopupControl class,
and its ContextMenu and Tooltip subclasses, to provide these predefined (coded)
JavaFX UI controls.
The DirectoryChooser and FileChooser classes give support for passing through
the standard OS file selection and directory navigation dialogs into your JavaFX ap-
plications. The FileChooser.ExtensionFilter nested class offers a utility for filtering
the files that will come up in the FileChooser dialog, based on file type (file extension).
Next, let's take your current InvinciBagel Stage object to the next level and make it
a windowless (floating) application. This is one of the impressive features of JavaFX
that cannot be matched by Flash or other game engines.
Using a JavaFX Primary Stage Object: Creating a Float-
ing Windowless Application
Let's make the primary Stage for your InvinciBagel application transparent so that the
Button UI control floats right on top of the OS desktop. This is something that JavaFX
can do that you do not see very often, and it allows you to create 3D applications that
float on top of the OS desktop (for 3D virtual objects, this is called a windowless Act-
iveX control).
This is accomplished by using the StageStyle.TRANSPARENT constant, in con-
junction with the .initStyle() method, from the Stage class. As Figure 4-4 demon-
strates, I also used the technique I told you about in Chapter 3 (a technique that does
not follow the proper Java coding convention regarding declaring an import statement
for classes you are planning to use). In line 35 of the code, I reference the constant by
using the fully qualified class name (package.subpackage.class.constant),
javafx.stage.StageStyle.TRANSPARENT , inside the
primaryStage.initStyle(StageStyle style) method call. This is done via the following
line of Java code:
 
Search WWH ::




Custom Search