Java Reference
In-Depth Information
not be invoked during object creation. Now when we assign a value to
status
,
the state changes to
initialized
, so
commenceTest
is now invoked. Please note
that if we had assigned a default value to
status
, even if that value is 0, then
status
immediately is set to
initialized
. The following example demon-
strates this.
public class Test {
public var status: Number
= 0
on replace {
// will be initialized immediately.
if(
isInitialized
(status)) {
commenceTest(status);
}
}
The last built-in function is
isSameObject()
.
isSameObject()
indicates if the
two arguments actually are the same instance. This is opposed to the
==
operator.
In JavaFX, the
==
operator determines whether two objects are considered equal,
but that does not mean they are the same instance. The
==
operator is similar to
the Java function
isEquals()
, whereas JavaFX
isSameObject
is similar to the
Java
==
operator. A little confusing if your background is Java!
The built-in variables are
__DIR__
and
__FILE__
.
__FILE__
holds the resource
URL string for the containing JavaFX class.
__DIR__
holds the resource URL
string for directory that contains the current class. For example,
println("DIR = {
__DIR__
}");
println("FILE = {
__FILE__
}");
// to locate an image
var image = Image { url: "{
__DIR__
}images/foo.jpeg" };
The following examples show the output from a directory based classpath versus
using a JAR-based class path.
Using a Jar file in classpath
$javafx -cp Misc.jar misc.Test
DIR = jar:file:/export/home/jclarke/Documents/
Book/FX/code/Chapter3/Misc/dist/Misc.jar!/misc/
FILE = jar:file:/export/home/jclarke/Documents/
Book/FX/code/Chapter3/Misc/dist/Misc.jar!/misc/Test.class
continues
Search WWH ::
Custom Search