Java Reference
In-Depth Information
println("This is a bar with id {pb.genId()}");
class Foo {
public function print(): Void {
println("The foo is {size} nibblets big!");
public function makeFoo(): Void Foo ( {
Foo { };
3. Once you have created the script module, you can reuse the module anywhere in
your code. You can see the usage of the module in file ch02/source-code/src/
module/ModuleDemo.fx as shown next:
println ("FooBar seed = {FooBarModule.seed}");
println ("FooBar size = {FooBarModule.size}");
FooBarModule.seed = 200000;
def bar = FooBarModule.Bar{};
How it works...
A module is a standalone JavaFX script file that contains definitions for classes, functions,
and variables. Let's examine the module presented in this recipe:
F Script-level-members—a module is comprised of both public and script-scoped
members, including variable declarations, class definitions, and functions. Public
members can be reached by code outside of the module such as variables size ,
seed , and class Bar . Script-only members (those with no access modifiers) ) can
only be accessed by members of the module (such as class Foo ).
F Class-definitions—classes marked as being public are reachable by client code
both inside and outside of the module. A script-only class definition is accessible
only by members in the same module. For instance, class Foo can only be accessed
by other members in the module.
F Function-members—JavaFX functions can also be defined as top-level members of
a module. Functions marked public can be reached by client code outside of the
module while script-only functions are only visible to members of the same module.
Search WWH ::

Custom Search