Java Reference
In-Depth Information
F CheckBox —similar to RadioButton , the CheckBox control is labeled entity, used to
let the user make multiple selections. It exposes properties to control the CheckBox's
label, font, icon, and, most importantly, the selection state.
F Button —the last controls used in the form is the Button . This class represents
regular push button controls, used to execute an action when clicked. As a labeled
entity, you can control the label's text, the font, and the icon for the button. The
Button instances also expose the action:function() property to let developers
specify what happens when the button is clicked.
There's more...
Once you have created a form using JavaFX, then what? How do you retrieve the data that is
stored in the control? Fortunately, JavaFX offers an easy way to search for a control (or any
node) you place in the scene graph. Recall that each control that receives input data has
the id:String property. This property provides a reference for the control, where it can be
searched in the scene graph tree.
The following code segment shows how to retrieve the text data stored in the TextBox instance
identified as city :
var scene:Scene;
var city = (scene.lookup("city") as TextBox).text
Stage{
scene: scene = Scene {...}
}
The code uses the Scene.lookup(id:String):Node script-level function to search for
a given node in the scene graph. You can see the full example of how this is used in the
source code from ch04/source-code/src/DataFormDemo.fx . When the Submit
button is clicked, the function goes through and collects data from all of the input controls
and displays it in a panel, as shown in the next screenshot:
 
Search WWH ::




Custom Search