Game Development Reference
In-Depth Information
Pos Constant
Positioning Result (Object)
BOTTOM_LEFT
On the bottom, vertically; on the left, horizontally
BOTTOM_RIGHT
On the bottom, vertically; on the right, horizontally
CENTER
At the center, vertically and horizontally
CENTER_LEFT
At the center, vertically; on the left, horizontally
CENTER_RIGHT
At the center, vertically; on the right, horizontally
TOP_CENTER
At the top, vertically; at the center, horizontally
TOP_LEFT
At the top, vertically; on the left, horizontally
TOP_RIGHT
At the top, vertically; on the right, horizontally
Because the Pos class offers generalized positioning, it should be used in conjunc-
tion with the Insets class to effect pixel-precise positioning. Let's take a look at the In-
sets class next, as it is also in the javafx.geometry package.
TheJavaFXInsetsClass:ProvidingPaddingValuesfor
Your UI
The Insets class is a public class that directly extends the java.lang.Object masterclass,
meaning that the Insets class was coded from scratch to provide insets, or offsets inside
a rectangular area. Imagine a picture frame in which you place a mat, or an attractive
border between the frame on the outside and the picture on the inside. This is what the
Insets class does with two constructor methods: one provides equal , or even, insets,
and the other, unequal , or uneven, insets.
You will be using the constructor that offers unequal insets values, which would
look very unprofessional if you were framing a picture! The Java class hierarchy for
the Insets class starts with the java.lang.Object master class and uses this class to cre-
ate the javafx.geometry.Insets class. As Figure 6-4 illustrates (l. 5), Insets is contained
in the JavaFX geometry package, just like the Pos class, and uses the following class
hierarchy structure:
java.lang.Object
> javafx.geometry. Insets
The Insets class furnishes a set of four double offset values specifying the four
sides ( top , right , bottom , left ) of a rectangle, which should be specified in that order
Search WWH ::




Custom Search