Java Reference
In-Depth Information
Chapter 11
Using JavaFX in Nashorn
In this chapter, you will learn:
jjs
command-line tool
•
The JavaFX support in the
init()
,
start()
, and
stop()
methods of the JavaFX
Application
class in scripts
•
Providing an implementation for the
•
How to load and use JavaFX packages and classes using the
predefined scripts
•
Creating and launching a simple JavaFX application using a
Nashorn script
Throughout this chapter, it is assumed that you have beginner-level experience in
JavaFX 8. If you do not have experience in JavaFX, please learn JavaFX before reading
this chapter.
JavaFX Support in jjs
The
jjs
command-line tool lets you launch JavaFX applications created in Nashorn
scripts. You need to use the
-fx
option with the
jjs
tool to run a script as a JavaFX
application. The following command runs a script stored in the
myfxapp.js
file as a
JavaFX application:
jjs -fx myfxapp.js
Structure of JavaFX Applications in Scripts
In a JavaFX application, you override the following three methods of the
Application
class to manage the lifecycle of the application:
•
The
init()
method
•
The
start()
method
•
The
stop()
method
Search WWH ::
Custom Search