Java Reference
In-Depth Information
When the panel variable is added to a scene and the application is executed, it will create a
form as shown in the next screenshot:
How it works...
The form created in this recipe uses several of the standard GUI controls found in JavaFX.
Thought the code looks intimidating, each row in the form is organized as merely a series of
repeating VBox and HBox layout managers assigned to a corresponding variable. Each row is
then assembled in a VBox instance assigned to the variable panel . Let's take a closer look at
the controls.
F Label —as you can guess, the Label control is normally used to affix a label for
another control. Though basic in its functionalities, the Label class exposes a
myriad of properties to control the font attributes, position, icon image, text
behavior in constrained spaces, and text wrapping behaviors. In our example,
we simply use the labels to label text boxes and other GUI controls the form.
F TextBox —this is the control designated to collect and display textual data using
free-form text. The JavaFX TextBox class makes several useful properties available,
including a watermark prompt (displayed prior to text entry), font attributes, the size
of the text box, and the text that was entered.
F RadioButton —this control is designed to function as a toggle button when the
user needs to select one item from two or more choices. Similar to other controls,
the RadioButton exposes several properties to control the button's label, font,
icon, and selection state. To get RadioButton instances to toggle as a group, you
must specify a ToggleGroup instance through the toggleGroup:ToggleGroup
property. In the recipe, we define variable rdoBtns as the ToggleGroup instance
for all three instances of the radio button.
 
Search WWH ::




Custom Search