The JavaFX AppletStageExtension provides browser specific functonality to the common Stage running in a script. Its primary function is to assist in the transition of a script dragged from a broswer environment and put into a desktop environment. The AppletStageExtension has two different use cases depending on the value of useDefaultClose.

Applet Stage Extension

   

For Applet mode, click on above image.

    Source code at a glance. 
var url1:String = FX.getArgument("clickTag1") as String;
var url2:String = FX.getArgument("clickTag2") as String;
var applet = FX.getArgument("javafx.applet") as java.applet.Applet;
Read the arguments clickTag1 and clickTag2 specified in FX Applet script as url1 and url2. Get the applet object. [
javafx(
        {
              archive: "AppDeployDemo.jar",
              width: 400,
              height: 600,
              code: "AppDeployDemo",
              name: "Java FX AppDeploy Demo"
        }, 
        {
             draggable: "true",
             clickTag1: "http://www.pogo.com",
             clickTag2: "http://www.zembly.com"

        }
    );
] ....
Rectangle {....             onMouseClicked: function(e: MouseEvent): Void {
                  AppletStageExtension.showDocument(url1);
            }
Requests that the browser to show the web page indicated by the url1 argument, which will load the url1 in the same page where the applet is running.
Rectangle {....            onMouseClicked: function(e: MouseEvent): Void {
                  AppletStageExtension.showDocument(url2,"New Javafx window");
            }

Requests that the browser show the web page ind icated by the url2 argument. The target argument indicates in which HTML frame the document is to be displayed. The target argument is interpreted as follows:

Target ArgumentDescription
"_self" Show in the window and frame that contain the applet.
"_parent"Show in the applet's parent frame. If the applet's frame has no parent frame, acts the same as "_self".
"_top" Show in the top-level frame of the applet's window. If the applet's frame is the top-level frame, acts the same as "_self".
"_blank" Show in a new, unnamed top-level window.
nameShow in the frame or window named name. If a target named name does not already exist, a new top-level window with the specified name is created, and the document is shown there.

Note that the browser is free to ignore showDocument. This method has no effect if not running in an applet environment.

var s: Stage = Stage {
    title: "AppDeploy Demo" .....
extensions: [ AppletStageExtension {             shouldDragStart: function(e: MouseEvent): Boolean {
                println("AppDeployDemo.shouldDragStart");
                return e.shiftDown and e.primaryButtonDown;
            }
            onDragStarted: function(): Void {
                println("AppDeployDemo.onDragStart");
            }
            onDragFinished: function(): Void {
                println("AppDeployDemo.onDragFinished");
            }
            onAppletRestored: function(): Void {
                println("AppDeployDemo.onAppletRestored");
            }
            useDefaultClose: false
} ]}
onDragStarted - This function is called at the start of the browser applet drag sequence onDragFinished - This function is called to indicate that the browser applet drag sequence has completed shouldDragStart - This function is called by the browser at the start of a mouse event that might cause a drag out of the browser. We can override the default drag behaviour using this function. Here Shift + Left Mouse Button is used for dragging the applet out. onAppletRestored - This function is called after the out of browser applet has been closed and returned to its environment within the browser. useDefaultClose - This attribute designates whether the default close box behvior is to be used once the applet has been dragged out of the browser, or whether the developer will be taking care of presenting the graphical close mechanism and taking care closing the Stage programmatically. ...
var jsArg1 = ["jsobject.call  JS Alert Test"];
var jsArg2:String = "alert('Alert Test using eval from Java Applet')";
var jsobject:JSObject = JSObject.getWindow(applet);
jsobject.call("alert", jsArg1);
jsobject.eval(jsArg2);
You can use netscape.javascript.JSObject to call a Java Script method.
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by Raghu Nair