APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.web

public final Class WebView

extends Parent
Class Inheritance
Imports
com.sun.java.scene.web.WebViewHelper, javafx.beans.property.BooleanProperty, .DoubleProperty, .ObjectProperty, .ReadOnlyDoubleProperty, .ReadOnlyDoubleWrapper, javafx.beans.value.WritableValue, javafx.collections.ObservableList, javafx.css.CssMetaData, .Styleable, .StyleableBooleanProperty, .StyleableDoubleProperty, .StyleableObjectProperty, .StyleableProperty, javafx.css.converter.ColorConverter, .BooleanConverter, .EnumConverter, .SizeConverter, javafx.event.EventHandler, .EventType, javafx.geometry.NodeOrientation, .Point2D, javafx.scene.Node, .Parent, javafx.scene.input.DataFormat, .DragEvent, .Dragboard, .InputMethodEvent, .KeyEvent, .MouseButton, .MouseEvent, .ScrollEvent, .TransferMode, javafx.scene.paint.Color, javafx.scene.text.FontSmoothingType, javafx.stage.Stage, .Window, java.util.ArrayList, .Collections, .LinkedList, .List, .Map, com.sun.javafx.geom.BaseBounds, .PickRay, com.sun.javafx.geom.transform.BaseTransform, com.sun.javafx.scene.DirtyBits, .NodeHelper, .SceneHelper, com.sun.javafx.scene.input.PickResultChooser, com.sun.javafx.sg.prism.NGNode, com.sun.javafx.sg.prism.web.NGWebView, com.sun.javafx.tk.TKPulseListener, .Toolkit, com.sun.javafx.webkit.InputMethodClientImpl, .KeyCodeMap, com.sun.webkit.WebPage, com.sun.webkit.event.WCFocusEvent, .WCInputMethodEvent, .WCKeyEvent, .WCMouseEvent, .WCMouseWheelEvent

WebView is a javafx.scene.Node that manages a WebEngine and displays its content. The associated WebEngine is created automatically at construction time and cannot be changed afterwards. WebView handles mouse and some keyboard events, and manages scrolling automatically, so there's no need to put it into a ScrollPane.

WebView objects must be created and accessed solely from the FX thread.

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
WebView.StyleableProperties

Super-lazy instantiation pattern from Bill Pugh.

Field Summary

Modifier and TypeField and Description
private BooleanProperty
contextMenuEnabled

Specifies whether context menu is enabled.

private static final boolean
private static final double
private static final FontSmoothingType
private static final double
private static final double
private static final double
private static final double
private static final Color
private static final double
private static final double
private static final double
private final WebEngine
private DoubleProperty
fontScale

Specifies scale factor applied to font.

private ObjectProperty<FontSmoothingType>
fontSmoothingType

Specifies a requested font smoothing type : gray or LCD.

private final ReadOnlyDoubleWrapper
private static final Map<Object, Integer>
private volatile InputMethodClientImpl
private DoubleProperty
private DoubleProperty
private LinkedList<String>
private DoubleProperty
private DoubleProperty
private final WebPage
private ObjectProperty<Color>
pageFill

Specifies the background color of the web page.

private DoubleProperty
private DoubleProperty
private final TKPulseListener
stagePulseListener

The stage pulse listener registered with the toolkit.

private LinkedList<String>
private final ReadOnlyDoubleWrapper
private static final int
private static final int
private static final int
private static final int
private DoubleProperty

Constructor Summary

AccessConstructor and Description
public
WebView()

Creates a WebView object.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty
private boolean
doComputeContains(double localX, double localY)

Hides javafx.scene.Parent.doComputeContains.

private BaseBounds
private NGNode
private void
private void
private void
public DoubleProperty
public final ObjectProperty<FontSmoothingType>
protected ObservableList<Node>
getChildren()

Overrides javafx.scene.Parent.getChildren.

Gets the list of children of this Parent.

public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.Node.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public List<CssMetaData<? extends Styleable, ?>>
getCssMetaData()

Overrides javafx.scene.Node.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

public final WebEngine

Returns:

the WebEngine
getEngine
()

Returns the WebEngine object.

public final double
public final FontSmoothingType
private static TransferMode[]
getFXDndAction(int wkDndAction)

public final double
private InputMethodClientImpl
public final double
public final double
public final double
public final double
public final Color
public final double
public final double
public final double
private static int
private static int
public final double
private void
public ReadOnlyDoubleProperty

Returns:

the height property
heightProperty
()

Height of this WebView.

public final boolean
public boolean
isResizable()

Overrides javafx.scene.Node.isResizable.

Indicates whether this node is a type which can be resized by its parent.

private boolean
public final double

Returns:

the maximum height that this node should be resized to during layout
maxHeight
(double width)

Overrides javafx.scene.Node.maxHeight.

Called during layout to determine the maximum height for this node.

public DoubleProperty

Returns:

the maxHeight property
maxHeightProperty
()

Maximum height property.

public final double

Returns:

the maximum width that this node should be resized to during layout
maxWidth
(double height)

Overrides javafx.scene.Node.maxWidth.

Called during layout to determine the maximum width for this node.

public DoubleProperty

Returns:

the maxWidth property
maxWidthProperty
()

Maximum width property.

public final double

Returns:

the minimum height that this node should be resized to during layout
minHeight
(double width)

Overrides javafx.scene.Parent.minHeight.

Called during layout to determine the minimum height for this node.

public DoubleProperty

Returns:

the minHeight property
minHeightProperty
()

Minimum height property.

public final double

Returns:

the minimum width that this node should be resized to during layout
minWidth
(double height)

Overrides javafx.scene.Parent.minWidth.

Called during layout to determine the minimum width for this node.

public DoubleProperty

Returns:

the minWidth property
minWidthProperty
()

Minimum width property.

public final ObjectProperty<Color>
public final double

Returns:

the preferred height that this node should be resized to during layout
prefHeight
(double width)

Overrides javafx.scene.Parent.prefHeight.

Called during layout to determine the preferred height for this node.

public DoubleProperty

Returns:

the prefHeight property
prefHeightProperty
()

Preferred height property.

public final double

Returns:

the preferred width that this node should be resized to during layout
prefWidth
(double height)

Overrides javafx.scene.Parent.prefWidth.

Called during layout to determine the preferred width for this node.

public DoubleProperty

Returns:

the prefWidth property
prefWidthProperty
()

Preferred width property.

private void
private void
private void
private void
private void
public void
resize(double width, double height)

Overrides javafx.scene.Node.resize.

If the node is resizable, will set its layout bounds to the specified width and height.

public final void
setContextMenuEnabled(boolean value)

public final void
setFontScale(double value)

public final void
public final void
setMaxHeight(double value)

public void
setMaxSize(double
the maximum width
maxWidth
,
double
the maximum height
maxHeight
)

Convenience method for setting maximum width and height.

public final void
setMaxWidth(double value)

public final void
setMinHeight(double value)

public void
setMinSize(double
the minimum width
minWidth
,
double
the minimum height
minHeight
)

Convenience method for setting minimum width and height.

public final void
setMinWidth(double value)

public final void
public final void
setPrefHeight(double value)

public void
setPrefSize(double
the preferred width
prefWidth
,
double
the preferred height
prefHeight
)

Convenience method for setting preferred width and height.

public final void
setPrefWidth(double value)

public final void
setZoom(double value)

public ReadOnlyDoubleProperty

Returns:

the width property
widthProperty
()

Width of this WebView.

public final DoubleProperty

Returns:

the zoom property
zoomProperty
()

The current zoom factor applied to the entire page contents.

Inherited from javafx.scene.Parent:
computeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthgetBaselineOffsetgetChildrenUnmodifiablegetManagedChildrengetStylesheetsisNeedsLayoutlayoutlayoutChildrenlookupneedsLayoutPropertyqueryAccessibleAttributerequestLayoutrequestParentLayoutsetNeedsLayoutupdateBounds

Field Detail

contextMenuEnabledback to summary
private BooleanProperty contextMenuEnabled

Specifies whether context menu is enabled.

Default Value
true
Since
JavaFX 2.2
DEFAULT_CONTEXT_MENU_ENABLEDback to summary
private static final boolean DEFAULT_CONTEXT_MENU_ENABLED
DEFAULT_FONT_SCALEback to summary
private static final double DEFAULT_FONT_SCALE
DEFAULT_FONT_SMOOTHING_TYPEback to summary
private static final FontSmoothingType DEFAULT_FONT_SMOOTHING_TYPE
DEFAULT_MAX_HEIGHTback to summary
private static final double DEFAULT_MAX_HEIGHT
DEFAULT_MAX_WIDTHback to summary
private static final double DEFAULT_MAX_WIDTH
DEFAULT_MIN_HEIGHTback to summary
private static final double DEFAULT_MIN_HEIGHT
DEFAULT_MIN_WIDTHback to summary
private static final double DEFAULT_MIN_WIDTH
DEFAULT_PAGE_FILLback to summary
private static final Color DEFAULT_PAGE_FILL
DEFAULT_PREF_HEIGHTback to summary
private static final double DEFAULT_PREF_HEIGHT
DEFAULT_PREF_WIDTHback to summary
private static final double DEFAULT_PREF_WIDTH
DEFAULT_ZOOMback to summary
private static final double DEFAULT_ZOOM
engineback to summary
private final WebEngine engine
fontScaleback to summary
private DoubleProperty fontScale

Specifies scale factor applied to font. This setting affects text content but not images and fixed size elements.

Default Value
1.0
fontSmoothingTypeback to summary
private ObjectProperty<FontSmoothingType> fontSmoothingType

Specifies a requested font smoothing type : gray or LCD. The width of the bounding box is defined by the widest row.

Note

LCD mode doesn't apply in numerous cases, such as various compositing modes, where effects are applied and very large glyphs.

Default Value
FontSmoothingType.LCD
Since
JavaFX 2.2
heightback to summary
private final ReadOnlyDoubleWrapper height
ID_MAPback to summary
private static final Map<Object, Integer> ID_MAP
imClientback to summary
private volatile InputMethodClientImpl imClient
maxHeightback to summary
private DoubleProperty maxHeight
maxWidthback to summary
private DoubleProperty maxWidth
mimesback to summary
private LinkedList<String> mimes
minHeightback to summary
private DoubleProperty minHeight
minWidthback to summary
private DoubleProperty minWidth
pageback to summary
private final WebPage page
pageFillback to summary
private ObjectProperty<Color> pageFill

Specifies the background color of the web page.

With this property, the WebView control's background can have any solid color, including some or complete level of transparency. However, if the HTML content being loaded sets its own background color, that color will take precedence.

Default Value
Color.WHITE
Since
18
prefHeightback to summary
private DoubleProperty prefHeight
prefWidthback to summary
private DoubleProperty prefWidth
stagePulseListenerback to summary
private final TKPulseListener stagePulseListener

The stage pulse listener registered with the toolkit. This field guarantees that the listener will exist throughout the whole lifetime of the WebView node. This field is necessary because the toolkit references its stage pulse listeners weakly.

valuesback to summary
private LinkedList<String> values
widthback to summary
private final ReadOnlyDoubleWrapper width
WK_DND_ACTION_COPYback to summary
private static final int WK_DND_ACTION_COPY
WK_DND_ACTION_MOVEback to summary
private static final int WK_DND_ACTION_MOVE
WK_DND_ACTION_NONEback to summary
private static final int WK_DND_ACTION_NONE
zoomback to summary
private DoubleProperty zoom

Constructor Detail

WebViewback to summary
public WebView()

Creates a WebView object.

Method Detail

contextMenuEnabledPropertyback to summary
public final BooleanProperty contextMenuEnabledProperty()
doComputeContainsback to summary
private boolean doComputeContains(double localX, double localY)

Hides javafx.scene.Parent.doComputeContains.

doComputeGeomBoundsback to summary
private BaseBounds doComputeGeomBounds(BaseBounds bounds, BaseTransform tx)

Hides javafx.scene.Parent.doComputeGeomBounds.

doCreatePeerback to summary
private NGNode doCreatePeer()

Hides javafx.scene.Parent.doCreatePeer.

doPickNodeLocalback to summary
private void doPickNodeLocal(PickRay pickRay, PickResultChooser result)

Hides javafx.scene.Parent.doPickNodeLocal.

doTransformsChangedback to summary
private void doTransformsChanged()

Hides javafx.scene.Node.doTransformsChanged.

doUpdatePeerback to summary
private void doUpdatePeer()

Hides javafx.scene.Parent.doUpdatePeer.

fontScalePropertyback to summary
public DoubleProperty fontScaleProperty()
fontSmoothingTypePropertyback to summary
public final ObjectProperty<FontSmoothingType> fontSmoothingTypeProperty()
getChildrenback to summary
protected ObservableList<Node> getChildren()

Overrides javafx.scene.Parent.getChildren.

Doc from javafx.scene.Parent.getChildren.

Gets the list of children of this Parent.

See the class documentation for Node for scene graph structure restrictions on setting a Parent's children list. If these restrictions are violated by a change to the list of children, the change is ignored and the previous value of the children list is restored. An IllegalArgumentException is thrown in this case.

If this Parent node is attached to a Scene attached to a Window, that is, showing (javafx.stage.Window#isShowing()), then its list of children must only be modified on the JavaFX Application Thread. An IllegalStateException is thrown if this restriction is violated.

Note to subclasses: if you override this method, you must return from your implementation the result of calling this super method. The actual list instance returned from any getChildren() implementation must be the list owned and managed by this Parent. The only typical purpose for overriding this method is to promote the method to be public.

Annotations
@Override
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.Node.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

Returns:List<CssMetaData<? extends Styleable, ?>>

the CssMetaData

Since
JavaFX 8.0
getCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData()

Overrides javafx.scene.Node.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.Node.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

Annotations
@Override
Since
JavaFX 8.0
getEngineback to summary
public final WebEngine getEngine()

Returns the WebEngine object.

Returns:WebEngine

the WebEngine

getFontScaleback to summary
public final double getFontScale()
getFontSmoothingTypeback to summary
public final FontSmoothingType getFontSmoothingType()
getFXDndActionback to summary
private static TransferMode[] getFXDndAction(int wkDndAction)
getHeightback to summary
public final double getHeight()
getInputMethodClientback to summary
private InputMethodClientImpl getInputMethodClient()
getMaxHeightback to summary
public final double getMaxHeight()
getMaxWidthback to summary
public final double getMaxWidth()
getMinHeightback to summary
public final double getMinHeight()
getMinWidthback to summary
public final double getMinWidth()
getPageFillback to summary
public final Color getPageFill()
getPrefHeightback to summary
public final double getPrefHeight()
getPrefWidthback to summary
public final double getPrefWidth()
getWidthback to summary
public final double getWidth()
getWKDndActionback to summary
private static int getWKDndAction(TransferMode... tms)
getWKDndEventTypeback to summary
private static int getWKDndEventType(EventType<T extends Event> et)
getZoomback to summary
public final double getZoom()
handleStagePulseback to summary
private void handleStagePulse()
heightPropertyback to summary
public ReadOnlyDoubleProperty heightProperty()

Height of this WebView.

Returns:ReadOnlyDoubleProperty

the height property

isContextMenuEnabledback to summary
public final boolean isContextMenuEnabled()
isResizableback to summary
public boolean isResizable()

Overrides javafx.scene.Node.isResizable.

Doc from javafx.scene.Node.isResizable.

Indicates whether this node is a type which can be resized by its parent. If this method returns true, then the parent will resize the node (ideally within its size range) by calling node.resize(width,height) during the layout pass. All Regions, Controls, and WebView are resizable classes which depend on their parents resizing them during layout once all sizing and CSS styling information has been applied.

If this method returns false, then the parent cannot resize it during layout (resize() is a no-op) and it should return its layoutBounds for minimum, preferred, and maximum sizes. Group, Text, and all Shapes are not resizable and hence depend on the application to establish their sizing by setting appropriate properties (e.g. width/height for Rectangle, text on Text, and so on). Non-resizable nodes may still be relocated during layout.

Annotations
@Override
isTreeReallyVisibleback to summary
private boolean isTreeReallyVisible()
maxHeightback to summary
public final double maxHeight(double width)

Overrides javafx.scene.Node.maxHeight.

Called during layout to determine the maximum height for this node.

Returns:double

the maximum height that this node should be resized to during layout

Annotations
@Override
maxHeightPropertyback to summary
public DoubleProperty maxHeightProperty()

Maximum height property.

Returns:DoubleProperty

the maxHeight property

maxWidthback to summary
public final double maxWidth(double height)

Overrides javafx.scene.Node.maxWidth.

Called during layout to determine the maximum width for this node.

Returns:double

the maximum width that this node should be resized to during layout

Annotations
@Override
maxWidthPropertyback to summary
public DoubleProperty maxWidthProperty()

Maximum width property.

Returns:DoubleProperty

the maxWidth property

minHeightback to summary
public final double minHeight(double width)

Overrides javafx.scene.Parent.minHeight.

Called during layout to determine the minimum height for this node.

Returns:double

the minimum height that this node should be resized to during layout

Annotations
@Override
minHeightPropertyback to summary
public DoubleProperty minHeightProperty()

Minimum height property.

Returns:DoubleProperty

the minHeight property

minWidthback to summary
public final double minWidth(double height)

Overrides javafx.scene.Parent.minWidth.

Called during layout to determine the minimum width for this node.

Returns:double

the minimum width that this node should be resized to during layout

Annotations
@Override
minWidthPropertyback to summary
public DoubleProperty minWidthProperty()

Minimum width property.

Returns:DoubleProperty

the minWidth property

pageFillPropertyback to summary
public final ObjectProperty<Color> pageFillProperty()
prefHeightback to summary
public final double prefHeight(double width)

Overrides javafx.scene.Parent.prefHeight.

Called during layout to determine the preferred height for this node.

Returns:double

the preferred height that this node should be resized to during layout

Annotations
@Override
prefHeightPropertyback to summary
public DoubleProperty prefHeightProperty()

Preferred height property.

Returns:DoubleProperty

the prefHeight property

prefWidthback to summary
public final double prefWidth(double height)

Overrides javafx.scene.Parent.prefWidth.

Called during layout to determine the preferred width for this node.

Returns:double

the preferred width that this node should be resized to during layout

Annotations
@Override
prefWidthPropertyback to summary
public DoubleProperty prefWidthProperty()

Preferred width property.

Returns:DoubleProperty

the prefWidth property

processInputMethodEventback to summary
private void processInputMethodEvent(InputMethodEvent ie)
processKeyEventback to summary
private void processKeyEvent(KeyEvent ev)
processMouseEventback to summary
private void processMouseEvent(MouseEvent ev)
processScrollEventback to summary
private void processScrollEvent(ScrollEvent ev)
registerEventHandlersback to summary
private void registerEventHandlers()
resizeback to summary
public void resize(double width, double height)

Overrides javafx.scene.Node.resize.

Doc from javafx.scene.Node.resize.

If the node is resizable, will set its layout bounds to the specified width and height. If the node is not resizable, this method is a no-op.

This method should generally only be called by parent nodes from their layoutChildren() methods. All Parent classes will automatically resize resizable children, so resizing done directly by the application will be overridden by the node's parent, unless the child is unmanaged.

Parents are responsible for ensuring the width and height values fall within the resizable node's preferred range. The autosize() method may be used if the parent just needs to resize the node to its preferred size.

Annotations
@Override
setContextMenuEnabledback to summary
public final void setContextMenuEnabled(boolean value)
setFontScaleback to summary
public final void setFontScale(double value)
setFontSmoothingTypeback to summary
public final void setFontSmoothingType(FontSmoothingType value)
setMaxHeightback to summary
public final void setMaxHeight(double value)
setMaxSizeback to summary
public void setMaxSize(double maxWidth, double maxHeight)

Convenience method for setting maximum width and height.

Parameters
maxWidth:double

the maximum width

maxHeight:double

the maximum height

setMaxWidthback to summary
public final void setMaxWidth(double value)
setMinHeightback to summary
public final void setMinHeight(double value)
setMinSizeback to summary
public void setMinSize(double minWidth, double minHeight)

Convenience method for setting minimum width and height.

Parameters
minWidth:double

the minimum width

minHeight:double

the minimum height

setMinWidthback to summary
public final void setMinWidth(double value)
setPageFillback to summary
public final void setPageFill(Color value)
setPrefHeightback to summary
public final void setPrefHeight(double value)
setPrefSizeback to summary
public void setPrefSize(double prefWidth, double prefHeight)

Convenience method for setting preferred width and height.

Parameters
prefWidth:double

the preferred width

prefHeight:double

the preferred height

setPrefWidthback to summary
public final void setPrefWidth(double value)
setZoomback to summary
public final void setZoom(double value)
widthPropertyback to summary
public ReadOnlyDoubleProperty widthProperty()

Width of this WebView.

Returns:ReadOnlyDoubleProperty

the width property

zoomPropertyback to summary
public final DoubleProperty zoomProperty()

The current zoom factor applied to the entire page contents.

Returns:DoubleProperty

the zoom property

Default Value
1.0
Since
JavaFX 8.0
javafx.scene.web back to summary

private final Class WebView.StyleableProperties

extends Object
Class Inheritance

Super-lazy instantiation pattern from Bill Pugh.

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<WebView, Boolean>
private static final CssMetaData<WebView, Number>
private static final CssMetaData<WebView, FontSmoothingType>
private static final CssMetaData<WebView, Number>
private static final CssMetaData<WebView, Number>
private static final CssMetaData<WebView, Number>
private static final CssMetaData<WebView, Number>
private static final CssMetaData<WebView, Color>
private static final CssMetaData<WebView, Number>
private static final CssMetaData<WebView, Number>
private static final List<CssMetaData<? extends Styleable, ?>>
private static final CssMetaData<WebView, Number>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONTEXT_MENU_ENABLEDback to summary
private static final CssMetaData<WebView, Boolean> CONTEXT_MENU_ENABLED
FONT_SCALEback to summary
private static final CssMetaData<WebView, Number> FONT_SCALE
FONT_SMOOTHING_TYPEback to summary
private static final CssMetaData<WebView, FontSmoothingType> FONT_SMOOTHING_TYPE
MAX_HEIGHTback to summary
private static final CssMetaData<WebView, Number> MAX_HEIGHT
MAX_WIDTHback to summary
private static final CssMetaData<WebView, Number> MAX_WIDTH
MIN_HEIGHTback to summary
private static final CssMetaData<WebView, Number> MIN_HEIGHT
MIN_WIDTHback to summary
private static final CssMetaData<WebView, Number> MIN_WIDTH
PAGE_FILLback to summary
private static final CssMetaData<WebView, Color> PAGE_FILL
PREF_HEIGHTback to summary
private static final CssMetaData<WebView, Number> PREF_HEIGHT
PREF_WIDTHback to summary
private static final CssMetaData<WebView, Number> PREF_WIDTH
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES
ZOOMback to summary
private static final CssMetaData<WebView, Number> ZOOM

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()