Java Reference
In-Depth Information
• By default, the
GridPane
contains two columns and three rows. You can add a row above or be-
low an existing row by right clicking a row and selecting
Grid Pane > Add Row Above
or
Grid
Pane > Add Row Below
. You can delete a row or column by right clicking the tab containing its
row or column number and selecting
Delete
.
•You can set a
Button
's text by double clicking it, or by selecting the
Button
, then setting its
Text
property in the
Inspector
window's
Properties
section.
•A
GridPane
column's contents are left-aligned by default. To change the alignment, select the
column by clicking the tab at the top or bottom of the column, then in the
Inspector
's
Layout
section, set the
Halignment
property.
• Setting a node's
Pref Width
property of a
GridPane
column to
USE_COMPUTED_SIZE
indicates that
the width should be based on the widest child.
•To size a
Button
the same width as the other controls in a
GridPane
's column, select the
Button
,
then in the
Inspector
's
Layout
section, set the
Max Width
property to
MAX_VALUE
.
• As you design your GUI, you can preview it in Scene Builder by selecting
Preview > Show Preview
in Window
.
• The space between a node's contents and its top, right, bottom and left edges is known as the
padding, which separates the contents from the node's edges. To set the padding, select the node,
then in the
Inspector
's
Layout
section, set the
Padding
property's values.
• You can specify the default amount of space between a
GridPane
's columns and rows with its
Hgap
(horizontal gap) and
Vgap
(vertical gap) properties, respectively.
• You can type in a
TextField
only if it's “in focus”—that is, it's the control that the user is inter-
acting with. When you click an interactive control, it receives the focus. Similarly, when you
press the
Ta b
key, the focus transfers from the current focusable control to the next one—this
occurs in the order the controls were added to the GUI.
Section 25.5.4
TipCalculator
Class
• To display a GUI, you must attach it to a
Scene
, then attach the
Scene
to the
Stage
that's passed
into
Application
method
start
.
•By default, the
Scene
's size is determined by the size of the scene graph's root node. Overloaded
versions of the
Scene
constructor allow you to specify the Scene's size and fill (a color, gradient
or image), which appears in the
c
's background.
•
Scene
method
setTitle
specifies the text that appears in the
Stage
window's title bar.
•
Stage
method
setScene
places a
Scene
onto a
Stage
.
•
Stage
method
show
displays the
Stage
window.
Section 25.5.5
TipCalculatorController
Class
•The
RoundingMode
enum
of package
java.math
is used to specify how
BigDecimal
values are
rounded during calculations or when formatting floating-point numbers as
String
s.
• Class
NumberFormat
of package
java.text
provides numeric formatting capabilities, such as lo-
cale-specific currency and percentage formats.
•A
Button
's event handler receives an
ActionEvent
, which indicates that the
Button
was clicked.
Many JavaFX controls support
ActionEvent
s.
•Package
javafx.scene.control
contains many JavaFX control classes.
•The
@FXML
annotation preceding an instance variable indicates that the variable's name can be
used in the FXML file that describes the app's GUI. The variable names that you specify in the
controller class must precisely match the
fx:id
values you specified when building the GUI.