Class WebView

All Implemented Interfaces:
Styleable, EventTarget

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 Details Link icon

  • Constructor Details Link icon

    • WebView Link icon

      public WebView()
      Creates a WebView object.
  • Method Details Link icon

    • getEngine Link icon

      public final WebEngine getEngine()
      Returns the WebEngine object.
      Returns:
      the WebEngine
    • getWidth Link icon

      public final double getWidth()
      Gets the value of the width property.
      Property description:
      Width of this WebView.
      Returns:
      the value of the width property
      See Also:
    • widthProperty Link icon

      public ReadOnlyDoubleProperty widthProperty()
      Width of this WebView.
      Returns:
      the width property
      See Also:
    • getHeight Link icon

      public final double getHeight()
      Gets the value of the height property.
      Property description:
      Height of this WebView.
      Returns:
      the value of the height property
      See Also:
    • heightProperty Link icon

      public ReadOnlyDoubleProperty heightProperty()
      Height of this WebView.
      Returns:
      the height property
      See Also:
    • setZoom Link icon

      public final void setZoom(double value)
      Sets the value of the zoom property.
      Property description:
      The current zoom factor applied to the entire page contents.
      Default value:
      1.0
      Parameters:
      value - the value for the zoom property
      Since:
      JavaFX 8.0
      See Also:
    • getZoom Link icon

      public final double getZoom()
      Gets the value of the zoom property.
      Property description:
      The current zoom factor applied to the entire page contents.
      Default value:
      1.0
      Returns:
      the value of the zoom property
      Since:
      JavaFX 8.0
      See Also:
    • zoomProperty Link icon

      public final DoubleProperty zoomProperty()
      The current zoom factor applied to the entire page contents.
      Default value:
      1.0
      Returns:
      the zoom property
      Since:
      JavaFX 8.0
      See Also:
    • setFontScale Link icon

      public final void setFontScale(double value)
      Sets the value of the fontScale property.
      Property description:
      Specifies scale factor applied to font. This setting affects text content but not images and fixed size elements.
      Default value:
      1.0
      Parameters:
      value - the value for the fontScale property
      See Also:
    • getFontScale Link icon

      public final double getFontScale()
      Gets the value of the fontScale property.
      Property description:
      Specifies scale factor applied to font. This setting affects text content but not images and fixed size elements.
      Default value:
      1.0
      Returns:
      the value of the fontScale property
      See Also:
    • fontScaleProperty Link icon

      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
      Returns:
      the fontScale property
      See Also:
    • minWidth Link icon

      public final double minWidth(double height)
      Called during layout to determine the minimum width for this node.
      Overrides:
      minWidth in class Node
      Parameters:
      height - the height that should be used if minimum width depends on it
      Returns:
      the minimum width that this node should be resized to during layout
      See Also:
    • minHeight Link icon

      public final double minHeight(double width)
      Called during layout to determine the minimum height for this node.
      Overrides:
      minHeight in class Node
      Parameters:
      width - the width that should be used if minimum height depends on it
      Returns:
      the minimum height that this node should be resized to during layout
      See Also:
    • prefWidth Link icon

      public final double prefWidth(double height)
      Called during layout to determine the preferred width for this node.
      Overrides:
      prefWidth in class Node
      Parameters:
      height - the height that should be used if preferred width depends on it
      Returns:
      the preferred width that this node should be resized to during layout
      See Also:
    • prefHeight Link icon

      public final double prefHeight(double width)
      Called during layout to determine the preferred height for this node.
      Overrides:
      prefHeight in class Node
      Parameters:
      width - the width that should be used if preferred height depends on it
      Returns:
      the preferred height that this node should be resized to during layout
      See Also:
    • maxWidth Link icon

      public final double maxWidth(double height)
      Called during layout to determine the maximum width for this node.
      Overrides:
      maxWidth in class Node
      Parameters:
      height - the height that should be used if maximum width depends on it
      Returns:
      the maximum width that this node should be resized to during layout
      See Also:
    • maxHeight Link icon

      public final double maxHeight(double width)
      Called during layout to determine the maximum height for this node.
      Overrides:
      maxHeight in class Node
      Parameters:
      width - the width that should be used if maximum height depends on it
      Returns:
      the maximum height that this node should be resized to during layout
      See Also:
    • minWidthProperty Link icon

      public DoubleProperty minWidthProperty()
      Minimum width property.
      Returns:
      the minWidth property
      See Also:
    • setMinWidth Link icon

      public final void setMinWidth(double value)
      Sets the value of the minWidth property.
      Property description:
      Minimum width property.
      Parameters:
      value - the value for the minWidth property
      See Also:
    • getMinWidth Link icon

      public final double getMinWidth()
      Gets the value of the minWidth property.
      Property description:
      Minimum width property.
      Returns:
      the value of the minWidth property
      See Also:
    • minHeightProperty Link icon

      public DoubleProperty minHeightProperty()
      Minimum height property.
      Returns:
      the minHeight property
      See Also:
    • setMinHeight Link icon

      public final void setMinHeight(double value)
      Sets the value of the minHeight property.
      Property description:
      Minimum height property.
      Parameters:
      value - the value for the minHeight property
      See Also:
    • getMinHeight Link icon

      public final double getMinHeight()
      Gets the value of the minHeight property.
      Property description:
      Minimum height property.
      Returns:
      the value of the minHeight property
      See Also:
    • setMinSize Link icon

      public void setMinSize(double minWidth, double minHeight)
      Convenience method for setting minimum width and height.
      Parameters:
      minWidth - the minimum width
      minHeight - the minimum height
    • prefWidthProperty Link icon

      public DoubleProperty prefWidthProperty()
      Preferred width property.
      Returns:
      the prefWidth property
      See Also:
    • setPrefWidth Link icon

      public final void setPrefWidth(double value)
      Sets the value of the prefWidth property.
      Property description:
      Preferred width property.
      Parameters:
      value - the value for the prefWidth property
      See Also:
    • getPrefWidth Link icon

      public final double getPrefWidth()
      Gets the value of the prefWidth property.
      Property description:
      Preferred width property.
      Returns:
      the value of the prefWidth property
      See Also:
    • prefHeightProperty Link icon

      public DoubleProperty prefHeightProperty()
      Preferred height property.
      Returns:
      the prefHeight property
      See Also:
    • setPrefHeight Link icon

      public final void setPrefHeight(double value)
      Sets the value of the prefHeight property.
      Property description:
      Preferred height property.
      Parameters:
      value - the value for the prefHeight property
      See Also:
    • getPrefHeight Link icon

      public final double getPrefHeight()
      Gets the value of the prefHeight property.
      Property description:
      Preferred height property.
      Returns:
      the value of the prefHeight property
      See Also:
    • setPrefSize Link icon

      public void setPrefSize(double prefWidth, double prefHeight)
      Convenience method for setting preferred width and height.
      Parameters:
      prefWidth - the preferred width
      prefHeight - the preferred height
    • maxWidthProperty Link icon

      public DoubleProperty maxWidthProperty()
      Maximum width property.
      Returns:
      the maxWidth property
      See Also:
    • setMaxWidth Link icon

      public final void setMaxWidth(double value)
      Sets the value of the maxWidth property.
      Property description:
      Maximum width property.
      Parameters:
      value - the value for the maxWidth property
      See Also:
    • getMaxWidth Link icon

      public final double getMaxWidth()
      Gets the value of the maxWidth property.
      Property description:
      Maximum width property.
      Returns:
      the value of the maxWidth property
      See Also:
    • maxHeightProperty Link icon

      public DoubleProperty maxHeightProperty()
      Maximum height property.
      Returns:
      the maxHeight property
      See Also:
    • setMaxHeight Link icon

      public final void setMaxHeight(double value)
      Sets the value of the maxHeight property.
      Property description:
      Maximum height property.
      Parameters:
      value - the value for the maxHeight property
      See Also:
    • getMaxHeight Link icon

      public final double getMaxHeight()
      Gets the value of the maxHeight property.
      Property description:
      Maximum height property.
      Returns:
      the value of the maxHeight property
      See Also:
    • setMaxSize Link icon

      public void setMaxSize(double maxWidth, double maxHeight)
      Convenience method for setting maximum width and height.
      Parameters:
      maxWidth - the maximum width
      maxHeight - the maximum height
    • setFontSmoothingType Link icon

      public final void setFontSmoothingType(FontSmoothingType value)
      Sets the value of the fontSmoothingType property.
      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
      Parameters:
      value - the value for the fontSmoothingType property
      Since:
      JavaFX 2.2
      See Also:
    • getFontSmoothingType Link icon

      public final FontSmoothingType getFontSmoothingType()
      Gets the value of the fontSmoothingType property.
      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
      Returns:
      the value of the fontSmoothingType property
      Since:
      JavaFX 2.2
      See Also:
    • fontSmoothingTypeProperty Link icon

      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
      Returns:
      the fontSmoothingType property
      Since:
      JavaFX 2.2
      See Also:
    • setPageFill Link icon

      public final void setPageFill(Color value)
      Sets the value of the pageFill property.
      Property description:
      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
      Parameters:
      value - the value for the pageFill property
      Since:
      18
      See Also:
    • getPageFill Link icon

      public final Color getPageFill()
      Gets the value of the pageFill property.
      Property description:
      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
      Returns:
      the value of the pageFill property
      Since:
      18
      See Also:
    • pageFillProperty Link icon

      public final ObjectProperty<Color> pageFillProperty()
      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
      Returns:
      the pageFill property
      Since:
      18
      See Also:
    • setContextMenuEnabled Link icon

      public final void setContextMenuEnabled(boolean value)
      Sets the value of the contextMenuEnabled property.
      Property description:
      Specifies whether context menu is enabled.
      Default value:
      true
      Parameters:
      value - the value for the contextMenuEnabled property
      Since:
      JavaFX 2.2
      See Also:
    • isContextMenuEnabled Link icon

      public final boolean isContextMenuEnabled()
      Gets the value of the contextMenuEnabled property.
      Property description:
      Specifies whether context menu is enabled.
      Default value:
      true
      Returns:
      the value of the contextMenuEnabled property
      Since:
      JavaFX 2.2
      See Also:
    • contextMenuEnabledProperty Link icon

      public final BooleanProperty contextMenuEnabledProperty()
      Specifies whether context menu is enabled.
      Default value:
      true
      Returns:
      the contextMenuEnabled property
      Since:
      JavaFX 2.2
      See Also:
    • getClassCssMetaData Link icon

      public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
      Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
      Returns:
      the CssMetaData
      Since:
      JavaFX 8.0
    • getCssMetaData Link icon

      public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
      This method should delegate to Node.getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.
      Specified by:
      getCssMetaData in interface Styleable
      Overrides:
      getCssMetaData in class Node
      Returns:
      The CssMetaData associated with this node, which may include the CssMetaData of its superclasses.
      Since:
      JavaFX 8.0