F The packaging of the code —the javafxpackager tool necessitates using the
-draggable flag so that it generates the applet artifacts accordingly. The
to include a draggable parameter set to true as shown next:
F Running the applet —the applet runs as would any normal applet. However, due to
the Stage extension defined in the code, it will respond to the mouse's drag gesture.
When a user starts dragging the applet body off the browser's page, the Java Plugin
will invoke callback function AppletStageExtension.shouldDragStart . If the
function returns true, then the applet will be allowed to be dragged off the page.
Otherwise the drag gesture will be ignored.
Before we leave this recipe, there are some additional items that we should address when
implementing drag-to-install behavior for our applets.
The JavaFX AppletStageExtension class provides a multitude of useful runtime
information and event hooks for your applet. Here are some you will find useful:
Use this flag to detect if the browser hosting the applet
supports out-of-page dragging.
When this flag is set to true (default), the applet will
automatically receive a floating close box to its right-
hand side (see previous figure). If set to false , the
developer is responsible for providing a mechanism for
closing the applet.
This is called after it has been determined that the
applet is being dragged.