Java Reference
In-Depth Information
JavaBeans: Please note that JavaFX triggers and JavaBeans have no built-in
connection. If you update a bean property, it will not automatically update a bound
JavaFX variable. The inverse is true too: if you update a JavaFX variable, it does
not automatically update a JavaBean property. In Chapter 12, JavaFX Code Reci-
pes, we present a way to do this, using Java property change listeners and JavaFX
on replace triggers.
When extending Java interfaces or Java abstract classes, the JavaFX class must
implement all the abstract methods contained within the interface or abstract
class or be declared abstract itself. These function signatures must be able to
map to the Java methods being implemented. For example, when extending the
java.awt.event.ActionListener interface, the Java method
public void actionPerformed(ActionEvent);
needs to be converted to a JavaFX function:
public override function
actionPerformed(e: ActionEvent) : Void { }
The override keyword is required, as this instructs the system that this method
overrides a method defined in the super class. The full example is
class MyActionListener extends
java.awt.event.ActionListener {
public override function
actionPerformed(e:java.awt.event.ActionEvent) :
Void {
// do something
}
}
Java Objects
You can instantiate Java objects from JavaFX using one of two methods. First, if
the Java object has a default (no args) constructor, you can use the JavaFX object
literal syntax. However, you cannot initialize any of the Java object's attributes
this way.
Developer Warning: The JavaFX compiler and runtime will allow you to enter
initializers for Java object attributes, but the compiler and runtime will just silently
ignore them. For example:
 
 
Search WWH ::




Custom Search