Game Development Reference
In-Depth Information
HBox(double spacing , Nodes... children ) - or, with zero
spacing value in between Node objects:
HBox(Nodes... children )
You are going to be using the “long form,” and .getChildren().addAll() method
chain, in your code, but you could also declare the HBox, and its Button Node objects,
by using the following constructor:
HBox buttonContainer = new HBox(12, gameButton,
helpButton, scoreButton, legalButton);
The HBox layout container will control resizing of child elements, based on differ-
ent screen sizes, aspect ratios, and physical resolutions if the child objects are set to be
resizable. If the HBox area will accommodate the child objects' preferred widths, they
will be set to that value. In addition, a fillHeight attribute (boolean variable) is set to
true , as the default value, specifying whether a child object should fill (scale up to) the
HBox height value.
Alignment of an HBox is controlled by the alignment attribute (property or vari-
able), which defaults to the TOP_LEFT constant from the Pos class
( Pos.TOP_LEFT ). If an HBox is sized above its specified width, the child objects use
their preferred width values, and the extra space goes unused. It is important to note
that the HBox layout engine will lay out the managed child elements, regardless of
their visibility attribute (property or variable) setting.
Now that I have discussed the JavaFX geometry and layout classes, which you will
be using to create the UI (a bank of Button objects) design, let's take a look at the digit-
al image-related classes, from the javafx.scene.image package, which will allow you to
implement the digital image-compositing pipeline that you will put in place behind
these four JavaFX Button UI control element objects held inside an HBox UI layout
container object.
The JavaFX Image Class: Referencing Digital Images
in a Design
The Image class is a public class that directly extends the java.lang.Object master-
class, meaning that the Image class was also coded from scratch to provide image load-
ing (referencing) and scaling (resizing). You can lock the aspect ratio for scaling and
Search WWH ::




Custom Search