Spec-Zone .ru
спецификации, руководства, описания, API

JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

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.


Default Close Example:

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.scene.input.*;
import javafx.stage.*;

Stage {
    title: "AppDeploy Demo"
    width : 300 height : 200
    style: StageStyle.TRANSPARENT
    opacity: 0.5
    scene : Scene {
            content: [
                Rectangle { x: 100 y: 100 width: 100 height: 100 
                            fill: Color.RED
                }
            ]
    }
    extensions: [
        AppletStageExtension {
            shouldDragStart: function(e: MouseEvent): Boolean {
                return e.shiftDown and e.primaryButtonDown;
            }
            useDefaultClose: true
        }
    ]
}
 

User-Specified Close Example:

import javafx.scene.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.scene.text.*;
import javafx.stage.*;

var textContent = "Click the box to return to the browser";
var outside: Boolean = false;

var s: Stage = Stage {
    title: "AppDeploy Demo"
    width : 300 height : 200
    style: StageStyle.TRANSPARENT
    opacity: 0.5
    scene : Scene {
            content: [
                Text { content: bind textContent  
                       x: 25 y:35 fill: Color.BLACK 
                       font: Font{size: 24} 
                }
                Rectangle { x: 100 y: 100 width: 100 height: 100 fill: Color.RED
                            onMouseClicked: function(e: MouseEvent): Void {
                                s.close();
                            }
                }
            ]
    }
    extensions: [
        AppletStageExtension {
            shouldDragStart: function(e: MouseEvent): Boolean {
                return e.shiftDown and e.primaryButtonDown;
            }
            useDefaultClose: false
        }
    ]
}
 

In the example above, a shift-click drags the applet from the browser and a click in the red Rectangle returns the Stage to the browser.

Profile: desktop

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
publicappletDragSupportedBoolean

appletDragSupported is set to true if the browser and its Java configuration support dragging applets from the browser to the desktop.

publiconAppletRestoredfunction():Void

This function is called after the out of browser applet has been closed and returned to its environment within the browser.

publiconDragFinishedfunction():Void

This function is called to indicate that the browser applet drag sequence has completed.

publiconDragStartedfunction():Void

This function is called at the start of the browser applet drag sequence.

publicshouldDragStartfunction(:MouseEvent):boolean

This function is called by the browser at the start of a mouse event that might cause a drag out of the browser.

public-inituseDefaultCloseBooleantrue

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.

Inherited Variables

Function Summary

public eval(javascript: java.lang.String) : java.lang.Object

Evaluates a JavaScript expression.

Evaluates a JavaScript expression. The expression is a string of JavaScript source code which will be evaluated in the context given by "this".

This method has no effect and returns null if not running in an applet environment.

Parameters
javascript

a String representing the JavaScript expression to be evaluated in the browser

Returns
Object
the result of the JavaScript evaluation
 
public showDocument(url: java.lang.String) : Void

Requests that the browser show the web page indicated by the url parameter.

Requests that the browser show the web page indicated by the url parameter. The browser determines which window or frame to display the web page. This method has no effect if not running in an applet environment.

Parameters
url

a String representing an absolute URL giving the location of the document

 
public showDocument(url: java.lang.String, target: java.lang.String) : Void

Requests that the browser show the web page indicated by the url argument.

Requests that the browser show the web page indicated by the url 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.

Parameters
url

a String representing an absolute URL giving the location of the document

target

a String indicating where to display the page

 

Inherited Functions