Java Reference
In-Depth Information
public class FXMLBasicFeaturesMain {
public static void main(String[] args) throws IOException {
FXMLBasicFeaturesBean bean = FXMLLoader.load(
FXMLBasicFeaturesMain.class.getResource(
"/projavafx/fxmlbasicfeatures/FXMLBasicFeatures.fxml")
);
System.out.println("bean = " + bean);
}
}
We made use of a small utility class that contains a few constants and a factory method that creates a
List<Integer> , as shown in Listing 3-13.
Listing 3-13. Utilities.java
package projavafx.fxmlbasicfeatures;
import java.util.ArrayList;
import java.util.List;
public class Utilities {
public static final Double TEN_PCT = 0.1d;
public static final Double TWENTY_PCT = 0.2d;
public static final Double THIRTY_PCT = 0.3d;
public static List<Integer> createList() {
return new ArrayList<>();
}
}
The FXMLBasicFeaturesBean object is being created in the FXML file; this is indicated by the fact that the
top-level element of the FXML file is FXMLBasicFeaturesBean . The name and address fields illustrate that a field can
be set either as an attribute or as a subelement:
<FXMLBasicFeaturesBean name="John Smith"
flag="true"
count="12345"
xmlns:fx=" http://javafx.com/fxml/1 " >
<address>12345 Main St.</address>
The foreground and background fields illustrate two ways of setting a javafx.scene.paint.Color
subelement, either through a hex string, or using a Color element (remember Color is an immutable object
without a default constructor):
<foreground>#ff8800</foreground>
<background>
<Color red="0.0" green="1.0" blue="0.5"/>
</background>
 
Search WWH ::




Custom Search