Java Reference
In-Depth Information
•
Nodes that have children are typically
layout containers
that arrange their child
nodes in the scene. You'll use two layout containers (
VBox
and
GridPane
) in this
chapter and learn several more in online Chapters 26-27.
•
The nodes arranged in a layout container are a combination of controls and, in
more complex GUIs, possibly other layout containers.
Controls
are GUI compo-
nents, such as
Label
s that display text,
TextField
s that enable a program to re-
ceive text typed by the user,
Button
s that initiate actions and more. When the
user interacts with a control, such as clicking a
Button
, the control generates an
event
. Programs can respond to these events—known as event handling—to
specify what should happen when each user interaction occurs.
•
An event handler is a method that responds to a user interaction. An FXML
GUI's event handlers are defined in a so-called
controller class
(as you'll see in
Section 25.5.5).
In this section,
without writing any code
you'll build a JavaFX
Welcome
app that displays text
in a
Label
and an image in an
ImageView
(Fig. 25.2). First, you'll create a JavaFX app project
in the
NetBeans IDE
. Then, you'll use visual-programming techniques and JavaFX Scene
Builder to
drag-and-drop
JavaFX components onto the design area. Next, you'll use JavaFX
Scene Builder's
Inspector
window to configure options, such as the
Labels
's text and font
size, and the
ImageView
's image. Finally, you'll execute the app from NetBeans. This section
assumes that you've read the Before You Begin section, and installed NetBeans and Scene
Builder. We used NetBeans 7.4, Scene Builder 1.1 and Java SE 7 for this chapter's examples.
Label
component
ImageView
components
Fig. 25.2
|
Final
Welcome
app running on Windows 7.
You'll now use NetBeans to create a
JavaFX FXML App
. Open NetBeans on your system.
Initially, the
Start Page
(Fig. 25.3) is displayed—this page gives you links to the NetBeans
documentation and displays a list of your recent projects, if any.