Java Reference
In-Depth Information
The abbreviations field illustrates how to populate a read-only map:
<abbreviations CA="California" NY="New York" FL="Florida" MO="Missouri"/>
When the FXMLBasicFeaturesMain program is run, the following output is printed to the console, as expected:
bean = FXMLBasicFeaturesBean{name='John Smith',
address='12345 Main St.',
flag=true,
count=12345,
foreground=0xff8800ff,
background=0x00ff80ff,
price=3.1415926,
discount=0.1,
sizes=[1, 2, 3],
profits={q1=1000, q2=1100, q3=1200, a4=1300},
inventory=9765625,
products=[widget, gadget, models],
abbreviations={MO=Missouri, FL=Florida, NY=New York, CA=California}}
Understanding Default and Static Properties
Many JavaFX classes have a default property. Default properties are specified with a @DefaultProperty annotation
on the class. The @DefaultProperty annotation belongs to the javafx.beans package. The default property of the
javafx.scene.Group class, for example, is its children property. In FXML files, when a default property is specified
via a subelement, the beginning and ending tag of the default property itself can be omitted. As an example, the
following snippet, which you saw in Listing 3-1,
<HBox fx:id="titleBox">
<children>
<Label fx:id="titleLabel"
text="title"/>
<TextField fx:id="titleTextField"
text="Stage Coach"/>
</children>
</HBox>
can be simplified to
<HBox fx:id="titleBox">
<Label fx:id="titleLabel"
text="title"/>
<TextField fx:id="titleTextField"
text="Stage Coach"/>
</HBox>
A static property is a property that is set on an object not by calling a setter method on the object itself, but by
calling a static method of a different class, passing both the object and the value of the property as parameters. Many
of JavaFX's container Node s have such static methods. These methods are called on a Node prior to adding it to the
 
Search WWH ::




Custom Search