Java Reference
In-Depth Information
How to do it...
To illustrate the techniques in this recipe, we will create a simple JavaFX application that
displays the current time and deploy that application as a drag-to-install applet.
1. The first thing to do is create a simple JavaFX script that uses an instance of the
Timeline class to drive a simple digital clock. The full listing of the code can be
found at ch07/source-code/src/draggable/DraggableApplet.fx .
var currTime = function():String{
new SimpleDateFormat("hh:mm:ss").format(new Date())
var time:String = currTime();
Timeline {
repeatCount:Timeline.INDEFINITE interpolate:false
keyFrames: KeyFrame {
time: 1s
action:function() {time = currTime()}
Stage {
scene: Scene {
content: [ ... //content omitted ]
extensions: [
AppletStageExtension {
shouldDragStart: function(e): Boolean {
return true;
useDefaultClose: true
2. Next, we compile and package the code using the javafxpackager . Notice that we
are specifying the -draggable flag:
javafxpackager -src src -appClass draggable.DraggableApplet
-appName draggable-applet
Search WWH ::

Custom Search