Class WebView
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.web.WebView
All Implemented Interfaces:
public final class WebView extends Parent
WebView is a 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
-
Property Summary
All MethodsInstance MethodsConcrete Methods Type Property and Description BooleanPropertycontextMenuEnabledSpecifies whether context menu is enabled.DoublePropertyfontScaleSpecifies scale factor applied to font.ObjectProperty<FontSmoothingType>fontSmoothingTypeSpecifies a requested font smoothing type : gray or LCD.ReadOnlyDoublePropertyheightHeight of thisWebView.DoublePropertymaxHeightMaximum height property.DoublePropertymaxWidthMaximum width property.DoublePropertyminHeightMinimum height property.DoublePropertyminWidthMinimum width property.DoublePropertyprefHeightPreferred height property.DoublePropertyprefWidthPreferred width property.ReadOnlyDoublePropertywidthWidth of thisWebView.DoublePropertyzoomReturns zoom property object.-
Properties inherited from class javafx.scene.Parent
needsLayout
-
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, visible
-
-
Field Summary
-
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
-
Constructor Summary
Constructors Constructor and Description WebView()Creates aWebViewobject.
-
Method Summary
All MethodsStatic MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description BooleanPropertycontextMenuEnabledProperty()Specifies whether context menu is enabled.DoublePropertyfontScaleProperty()Specifies scale factor applied to font.ObjectProperty<FontSmoothingType>fontSmoothingTypeProperty()Specifies a requested font smoothing type : gray or LCD.protected ObservableList<Node>getChildren()Gets the list of children of thisParent.static List<CssMetaData<? extends Styleable,?>>getClassCssMetaData()List<CssMetaData<? extends Styleable,?>>getCssMetaData()This method should delegate toNode.getClassCssMetaData()so that a Node's CssMetaData can be accessed without the need for reflection.WebEnginegetEngine()Returns theWebEngineobject.doublegetFontScale()Gets the value of the property fontScale.FontSmoothingTypegetFontSmoothingType()Gets the value of the property fontSmoothingType.doublegetHeight()Returns height of thisWebView.doublegetMaxHeight()Returns maximum height.doublegetMaxWidth()Returns maximum width.doublegetMinHeight()Sets minimum height.doublegetMinWidth()Returns minimum width.doublegetPrefHeight()Returns preferred height.doublegetPrefWidth()Returns preferred width.doublegetWidth()Returns width of thisWebView.doublegetZoom()Returns current zoom factor applied to the whole page contents.ReadOnlyDoublePropertyheightProperty()Height of thisWebView.booleanisContextMenuEnabled()Gets the value of the property contextMenuEnabled.booleanisResizable()Indicates whether this node is a type which can be resized by its parent.doublemaxHeight(double width)Called during layout to determine the maximum height for this node.DoublePropertymaxHeightProperty()Maximum height property.doublemaxWidth(double height)Called during layout to determine the maximum width for this node.DoublePropertymaxWidthProperty()Maximum width property.doubleminHeight(double width)Called during layout to determine the minimum height for this node.DoublePropertyminHeightProperty()Minimum height property.doubleminWidth(double height)Called during layout to determine the minimum width for this node.DoublePropertyminWidthProperty()Minimum width property.doubleprefHeight(double width)Called during layout to determine the preferred height for this node.DoublePropertyprefHeightProperty()Preferred height property.doubleprefWidth(double height)Called during layout to determine the preferred width for this node.DoublePropertyprefWidthProperty()Preferred width property.voidresize(double width, double height)If the node is resizable, will set its layout bounds to the specified width and height.voidsetContextMenuEnabled(boolean value)Sets the value of the property contextMenuEnabled.voidsetFontScale(double value)Sets the value of the property fontScale.voidsetFontSmoothingType(FontSmoothingType value)Sets the value of the property fontSmoothingType.voidsetMaxHeight(double value)Sets maximum height.voidsetMaxSize(double maxWidth, double maxHeight)Convenience method for setting maximum width and height.voidsetMaxWidth(double value)Sets maximum width.voidsetMinHeight(double value)Sets minimum height.voidsetMinSize(double minWidth, double minHeight)Convenience method for setting minimum width and height.voidsetMinWidth(double value)Sets minimum width.voidsetPrefHeight(double value)Sets preferred height.voidsetPrefSize(double prefWidth, double prefHeight)Convenience method for setting preferred width and height.voidsetPrefWidth(double value)Sets preferred width.voidsetZoom(double value)Sets current zoom factor applied to the whole page contents.ReadOnlyDoublePropertywidthProperty()Width of thisWebView.DoublePropertyzoomProperty()Returns zoom property object.-
Methods inherited from class javafx.scene.Parent
computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, layoutChildren, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
-
-
Property Detail
-
width
public ReadOnlyDoubleProperty widthProperty
Width of thisWebView.See Also:
-
height
public ReadOnlyDoubleProperty heightProperty
Height of thisWebView.See Also:
-
zoom
public final DoubleProperty zoomProperty
Returns zoom property object.
-
fontScale
public DoubleProperty fontScaleProperty
Specifies scale factor applied to font. This setting affects text content but not images and fixed size elements.Default value:
1.0
See Also:
-
minWidth
public DoubleProperty minWidthProperty
Minimum width property.See Also:
-
minHeight
public DoubleProperty minHeightProperty
Minimum height property.See Also:
-
prefWidth
public DoubleProperty prefWidthProperty
Preferred width property.See Also:
-
prefHeight
public DoubleProperty prefHeightProperty
Preferred height property.See Also:
-
maxWidth
public DoubleProperty maxWidthProperty
Maximum width property.See Also:
-
maxHeight
public DoubleProperty maxHeightProperty
Maximum height property.See Also:
-
fontSmoothingType
public final ObjectProperty<FontSmoothingType> fontSmoothingTypeProperty
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
-
contextMenuEnabled
public final BooleanProperty contextMenuEnabledProperty
Specifies whether context menu is enabled.Default value:
true
Since:
JavaFX 2.2
-
-
Constructor Detail
-
WebView
public WebView()
Creates aWebViewobject.
-
-
Method Detail
-
getEngine
public final WebEngine getEngine()
Returns theWebEngineobject.
-
getWidth
public final double getWidth()
Returns width of thisWebView.
-
widthProperty
public ReadOnlyDoubleProperty widthProperty()
Width of thisWebView.See Also:
-
getHeight
public final double getHeight()
Returns height of thisWebView.
-
heightProperty
public ReadOnlyDoubleProperty heightProperty()
Height of thisWebView.See Also:
-
setZoom
public final void setZoom(double value)
Sets current zoom factor applied to the whole page contents.
-
getZoom
public final double getZoom()
Returns current zoom factor applied to the whole page contents.
-
zoomProperty
public final DoubleProperty zoomProperty()
Returns zoom property object.
-
setFontScale
public final void setFontScale(double value)
Sets the value of the property fontScale.Property description:
Specifies scale factor applied to font. This setting affects text content but not images and fixed size elements.
Default value:
1.0
-
getFontScale
public final double getFontScale()
Gets the value of the property fontScale.Property description:
Specifies scale factor applied to font. This setting affects text content but not images and fixed size elements.
Default value:
1.0
-
fontScaleProperty
public DoubleProperty fontScaleProperty()
Specifies scale factor applied to font. This setting affects text content but not images and fixed size elements.Default value:
1.0
See Also:
-
isResizable
public boolean isResizable()
Description copied from class:NodeIndicates 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.
Overrides:
isResizablein classNodeReturns:
whether or not this node type can be resized by its parent during layout
-
resize
public void resize(double width, double height)Description copied from class:NodeIf 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.
Parameters:
width- the target layout bounds width
-
minWidth
public final double minWidth(double height)
Called during layout to determine the minimum width for this node.Parameters:
height- the height that should be used if minimum width depends on itReturns:
the minimum width that this node should be resized to during layout
See Also:
-
minHeight
public final double minHeight(double width)
Called during layout to determine the minimum height for this node.Parameters:
width- the width that should be used if minimum height depends on itReturns:
the minimum height that this node should be resized to during layout
See Also:
-
prefWidth
public final double prefWidth(double height)
Called during layout to determine the preferred width for this node.Parameters:
height- the height that should be used if preferred width depends on itReturns:
the preferred width that this node should be resized to during layout
See Also:
-
prefHeight
public final double prefHeight(double width)
Called during layout to determine the preferred height for this node.Overrides:
prefHeightin classParentParameters:
width- the width that should be used if preferred height depends on itReturns:
the preferred height that this node should be resized to during layout
See Also:
-
maxWidth
public final double maxWidth(double height)
Called during layout to determine the maximum width for this node.Parameters:
height- the height that should be used if maximum width depends on itReturns:
the maximum width that this node should be resized to during layout
See Also:
-
maxHeight
public final double maxHeight(double width)
Called during layout to determine the maximum height for this node.Parameters:
width- the width that should be used if maximum height depends on itReturns:
the maximum height that this node should be resized to during layout
See Also:
-
minWidthProperty
public DoubleProperty minWidthProperty()
Minimum width property.See Also:
-
setMinWidth
public final void setMinWidth(double value)
Sets minimum width.
-
getMinWidth
public final double getMinWidth()
Returns minimum width.
-
minHeightProperty
public DoubleProperty minHeightProperty()
Minimum height property.See Also:
-
setMinHeight
public final void setMinHeight(double value)
Sets minimum height.
-
getMinHeight
public final double getMinHeight()
Sets minimum height.
-
setMinSize
public void setMinSize(double minWidth, double minHeight)Convenience method for setting minimum width and height.
-
prefWidthProperty
public DoubleProperty prefWidthProperty()
Preferred width property.See Also:
-
setPrefWidth
public final void setPrefWidth(double value)
Sets preferred width.
-
getPrefWidth
public final double getPrefWidth()
Returns preferred width.
-
prefHeightProperty
public DoubleProperty prefHeightProperty()
Preferred height property.See Also:
-
setPrefHeight
public final void setPrefHeight(double value)
Sets preferred height.
-
getPrefHeight
public final double getPrefHeight()
Returns preferred height.
-
setPrefSize
public void setPrefSize(double prefWidth, double prefHeight)Convenience method for setting preferred width and height.
-
maxWidthProperty
public DoubleProperty maxWidthProperty()
Maximum width property.See Also:
-
setMaxWidth
public final void setMaxWidth(double value)
Sets maximum width.
-
getMaxWidth
public final double getMaxWidth()
Returns maximum width.
-
maxHeightProperty
public DoubleProperty maxHeightProperty()
Maximum height property.See Also:
-
setMaxHeight
public final void setMaxHeight(double value)
Sets maximum height.
-
getMaxHeight
public final double getMaxHeight()
Returns maximum height.
-
setMaxSize
public void setMaxSize(double maxWidth, double maxHeight)Convenience method for setting maximum width and height.
-
setFontSmoothingType
public final void setFontSmoothingType(FontSmoothingType value)
Sets the value of the property fontSmoothingType.Property description:
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
-
getFontSmoothingType
public final FontSmoothingType getFontSmoothingType()
Gets the value of the property fontSmoothingType.Property description:
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
-
fontSmoothingTypeProperty
public final ObjectProperty<FontSmoothingType> fontSmoothingTypeProperty()
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
-
setContextMenuEnabled
public final void setContextMenuEnabled(boolean value)
Sets the value of the property contextMenuEnabled.Property description:
Specifies whether context menu is enabled.
Default value:
true
Since:
JavaFX 2.2
-
isContextMenuEnabled
public final boolean isContextMenuEnabled()
Gets the value of the property contextMenuEnabled.Property description:
Specifies whether context menu is enabled.
Default value:
true
Since:
JavaFX 2.2
-
contextMenuEnabledProperty
public final BooleanProperty contextMenuEnabledProperty()
Specifies whether context menu is enabled.Default value:
true
Since:
JavaFX 2.2
-
getClassCssMetaData
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
Returns:
The CssMetaData associated with this class, which may include the CssMetaData of its super classes.
Since:
JavaFX 8.0
-
getCssMetaData
public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
This method should delegate toNode.getClassCssMetaData()so that a Node's CssMetaData can be accessed without the need for reflection.Specified by:
getCssMetaDatain interfaceStyleableOverrides:
getCssMetaDatain classNodeReturns:
The CssMetaData associated with this node, which may include the CssMetaData of its super classes.
Since:
JavaFX 8.0
-
getChildren
protected ObservableList<Node> getChildren()
Description copied from class:ParentGets the list of children of thisParent.See the class documentation for
Nodefor scene graph structure restrictions on setting aParent'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. AnIllegalArgumentExceptionis thrown in this case.If this
Parentnode is attached to aSceneattached to aWindowthat is showning (Window.isShowing()), then its list of children must only be modified on the JavaFX Application Thread. AnIllegalStateExceptionis 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.
Overrides:
getChildrenin classParentReturns:
the list of children of this
Parent.
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.