Spec-Zone .ru
спецификации, руководства, описания, API
|
public final class WebEngine
extends java.lang.Object
WebEngine
is a non-visual object capable of managing one Web page
at a time. One can load Web pages into an engine, track loading progress,
access document model of a loaded page, and execute JavaScript on the page.
Loading is always asynchronous. Methods that initiate loading return
immediately after scheduling a job, so one must not assume loading is
complete by that time. getLoadWorker()
method can be used to track
loading status.
A number of JavaScript handlers and callbacks may be registered with a
WebEngine
. These are invoked when a script running on the page
accesses user interface elements that lie beyond the control of the
WebEngine
, such as browser window, toolbar or status line.
WebEngine
objects must be created and accessed solely from the
FXthread.
Type | Property and Description |
---|---|
ObjectProperty<Callback<java.lang.String,java.lang.Boolean>> |
confirmHandler
JavaScript
confirm handler property. |
ObjectProperty<Callback<PopupFeatures,WebEngine>> |
createPopupHandler
JavaScript popup handler property.
|
ReadOnlyObjectProperty<org.w3c.dom.Document> |
document
Document object for the current Web page.
|
ReadOnlyStringProperty |
location
URL of the current Web page.
|
ObjectProperty<EventHandler<WebEvent<java.lang.String>>> |
onAlert
JavaScript
alert handler property. |
ObjectProperty<EventHandler<WebEvent<Rectangle2D>>> |
onResized
JavaScript window resize handler property.
|
ObjectProperty<EventHandler<WebEvent<java.lang.String>>> |
onStatusChanged
JavaScript status handler property.
|
ObjectProperty<EventHandler<WebEvent<java.lang.Boolean>>> |
onVisibilityChanged
JavaScript window visibility handler property.
|
ObjectProperty<Callback<PromptData,java.lang.String>> |
promptHandler
JavaScript
prompt handler property. |
ReadOnlyStringProperty |
title
Title of the current Web page.
|
Constructor and Description |
---|
WebEngine()
Creates a new engine.
|
WebEngine(java.lang.String url)
Creates a new engine and loads a Web page into it.
|
Modifier and Type | Method and Description |
---|---|
ObjectProperty<Callback<java.lang.String,java.lang.Boolean>> |
confirmHandlerProperty()
JavaScript
confirm handler property. |
ObjectProperty<Callback<PopupFeatures,WebEngine>> |
createPopupHandlerProperty()
JavaScript popup handler property.
|
ReadOnlyObjectProperty<org.w3c.dom.Document> |
documentProperty()
Document object for the current Web page.
|
java.lang.Object |
executeScript(java.lang.String script)
Executes a script in the context of the current page.
|
Callback<java.lang.String,java.lang.Boolean> |
getConfirmHandler()
Returns the JavaScript
confirm handler. |
Callback<PopupFeatures,WebEngine> |
getCreatePopupHandler()
Returns the JavaScript popup handler.
|
org.w3c.dom.Document |
getDocument()
Returns the document object for the current Web page.
|
Worker<java.lang.Void> |
getLoadWorker()
Returns a
Worker object that can be used to
track loading progress. |
java.lang.String |
getLocation()
Returns URL of the current Web page.
|
EventHandler<WebEvent<java.lang.String>> |
getOnAlert()
Returns the JavaScript
alert handler. |
EventHandler<WebEvent<Rectangle2D>> |
getOnResized()
Returns the JavaScript window resize handler.
|
EventHandler<WebEvent<java.lang.String>> |
getOnStatusChanged()
Returns the JavaScript status handler.
|
EventHandler<WebEvent<java.lang.Boolean>> |
getOnVisibilityChanged()
Returns the JavaScript window visibility handler.
|
Callback<PromptData,java.lang.String> |
getPromptHandler()
Returns the JavaScript
prompt handler. |
java.lang.String |
getTitle()
Returns title of the current Web page.
|
void |
load(java.lang.String url)
Loads a Web page into this engine.
|
void |
loadContent(java.lang.String content)
Loads the given HTML content directly.
|
void |
loadContent(java.lang.String content,
java.lang.String contentType)
Loads the given content directly.
|
ReadOnlyStringProperty |
locationProperty()
URL of the current Web page.
|
ObjectProperty<EventHandler<WebEvent<java.lang.String>>> |
onAlertProperty()
JavaScript
alert handler property. |
ObjectProperty<EventHandler<WebEvent<Rectangle2D>>> |
onResizedProperty()
JavaScript window resize handler property.
|
ObjectProperty<EventHandler<WebEvent<java.lang.String>>> |
onStatusChangedProperty()
JavaScript status handler property.
|
ObjectProperty<EventHandler<WebEvent<java.lang.Boolean>>> |
onVisibilityChangedProperty()
JavaScript window visibility handler property.
|
ObjectProperty<Callback<PromptData,java.lang.String>> |
promptHandlerProperty()
JavaScript
prompt handler property. |
void |
reload()
Reloads the current page, whether loaded from URL or directly from a String in
one of the
loadContent methods. |
void |
setConfirmHandler(Callback<java.lang.String,java.lang.Boolean> handler)
Sets the JavaScript
confirm handler. |
void |
setCreatePopupHandler(Callback<PopupFeatures,WebEngine> handler)
Sets the JavaScript popup handler.
|
void |
setOnAlert(EventHandler<WebEvent<java.lang.String>> handler)
Sets the JavaScript
alert handler. |
void |
setOnResized(EventHandler<WebEvent<Rectangle2D>> handler)
Sets the JavaScript window resize handler.
|
void |
setOnStatusChanged(EventHandler<WebEvent<java.lang.String>> handler)
Sets the JavaScript status handler.
|
void |
setOnVisibilityChanged(EventHandler<WebEvent<java.lang.Boolean>> handler)
Sets the JavaScript window visibility handler.
|
void |
setPromptHandler(Callback<PromptData,java.lang.String> handler)
Sets the JavaScript
prompt handler. |
ReadOnlyStringProperty |
titleProperty()
Title of the current Web page.
|
null
if the Web page failed to load.getDocument()
getLocation()
null
.getTitle()
alert
handler property. This handler is invoked
when a script running on the Web page calls the alert
function.getOnAlert()
,
setOnAlert(EventHandler)
window.status
property.window
object.getOnResized()
,
setOnResized(EventHandler)
window
object.To satisfy this request a handler may create a new WebEngine
,
attach a visibility handler and optionally a resize handler, and return
the newly created engine. To block the popup, a handler should return
null
.
By default, a popup handler is installed that opens popups in this
WebEngine
.
confirm
handler property. This handler is invoked
when a script running on the Web page calls the confirm
function.
An implementation may display a dialog box with Yes and No options, and return the user's choice.
prompt
handler property. This handler is invoked
when a script running on the Web page calls the prompt
function.
An implementation may display a dialog box with an text field, and return the user's input.
public WebEngine()
public WebEngine(java.lang.String url)
public final Worker<java.lang.Void> getLoadWorker()
Worker
object that can be used to
track loading progress.public final org.w3c.dom.Document getDocument()
null
.public final ReadOnlyObjectProperty<org.w3c.dom.Document> documentProperty()
null
if the Web page failed to load.getDocument()
public final java.lang.String getLocation()
public final ReadOnlyStringProperty locationProperty()
getLocation()
public final java.lang.String getTitle()
null
.public final ReadOnlyStringProperty titleProperty()
null
.getTitle()
public final EventHandler<WebEvent<java.lang.String>> getOnAlert()
alert
handler.public final void setOnAlert(EventHandler<WebEvent<java.lang.String>> handler)
alert
handler.onAlertProperty()
,
getOnAlert()
public final ObjectProperty<EventHandler<WebEvent<java.lang.String>>> onAlertProperty()
alert
handler property. This handler is invoked
when a script running on the Web page calls the alert
function.getOnAlert()
,
setOnAlert(EventHandler)
public final EventHandler<WebEvent<java.lang.String>> getOnStatusChanged()
public final void setOnStatusChanged(EventHandler<WebEvent<java.lang.String>> handler)
public final ObjectProperty<EventHandler<WebEvent<java.lang.String>>> onStatusChangedProperty()
window.status
property.public final EventHandler<WebEvent<Rectangle2D>> getOnResized()
public final void setOnResized(EventHandler<WebEvent<Rectangle2D>> handler)
onResizedProperty()
,
getOnResized()
public final ObjectProperty<EventHandler<WebEvent<Rectangle2D>>> onResizedProperty()
window
object.getOnResized()
,
setOnResized(EventHandler)
public final EventHandler<WebEvent<java.lang.Boolean>> getOnVisibilityChanged()
public final void setOnVisibilityChanged(EventHandler<WebEvent<java.lang.Boolean>> handler)
public final ObjectProperty<EventHandler<WebEvent<java.lang.Boolean>>> onVisibilityChangedProperty()
window
object.public final Callback<PopupFeatures,WebEngine> getCreatePopupHandler()
public final void setCreatePopupHandler(Callback<PopupFeatures,WebEngine> handler)
public final ObjectProperty<Callback<PopupFeatures,WebEngine>> createPopupHandlerProperty()
To satisfy this request a handler may create a new WebEngine
,
attach a visibility handler and optionally a resize handler, and return
the newly created engine. To block the popup, a handler should return
null
.
By default, a popup handler is installed that opens popups in this
WebEngine
.
public final Callback<java.lang.String,java.lang.Boolean> getConfirmHandler()
confirm
handler.public final void setConfirmHandler(Callback<java.lang.String,java.lang.Boolean> handler)
confirm
handler.confirmHandlerProperty()
,
getConfirmHandler()
public final ObjectProperty<Callback<java.lang.String,java.lang.Boolean>> confirmHandlerProperty()
confirm
handler property. This handler is invoked
when a script running on the Web page calls the confirm
function.
An implementation may display a dialog box with Yes and No options, and return the user's choice.
public final Callback<PromptData,java.lang.String> getPromptHandler()
prompt
handler.public final void setPromptHandler(Callback<PromptData,java.lang.String> handler)
prompt
handler.promptHandlerProperty()
,
getPromptHandler()
,
PromptData
public final ObjectProperty<Callback<PromptData,java.lang.String>> promptHandlerProperty()
prompt
handler property. This handler is invoked
when a script running on the Web page calls the prompt
function.
An implementation may display a dialog box with an text field, and return the user's input.
public void load(java.lang.String url)
url
- URL of the web page to loadpublic void loadContent(java.lang.String content)
load(String)
, this method is asynchronous.public void loadContent(java.lang.String content, java.lang.String contentType)
load(String)
, this method is asynchronous. This method also allows you to
specify the content type of the string being loaded, and so may optionally support
other types besides just HTML.public void reload()
loadContent
methods.public java.lang.Object executeScript(java.lang.String script)
java.lang.Integer
java.lang.Double
java.lang.String
java.lang.Boolean
null
to null
netscape.javascript.JSObject
netscape.javascript.JSObject
, that also implement
org.w3c.dom.Node
JavaRuntimeObject
which is used to wrap a Java object as a JavaScript value - in this
case we just extract the original Java value.
Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to