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.
Modifier and Type | Class and Description |
---|---|
private static class |
WebView.StyleableProperties
Super-lazy instantiation pattern from Bill Pugh.
|
Modifier and Type | Field and Description |
---|---|
private BooleanProperty |
contextMenuEnabled
Specifies whether context menu is enabled.
|
private static boolean |
DEFAULT_CONTEXT_MENU_ENABLED |
private static double |
DEFAULT_FONT_SCALE |
private static FontSmoothingType |
DEFAULT_FONT_SMOOTHING_TYPE |
private static double |
DEFAULT_MAX_HEIGHT |
private static double |
DEFAULT_MAX_WIDTH |
private static double |
DEFAULT_MIN_HEIGHT |
private static double |
DEFAULT_MIN_WIDTH |
private static double |
DEFAULT_PREF_HEIGHT |
private static double |
DEFAULT_PREF_WIDTH |
private static double |
DEFAULT_ZOOM |
private WebEngine |
engine |
private DoubleProperty |
fontScale
Specifies scale factor applied to font.
|
private ObjectProperty<FontSmoothingType> |
fontSmoothingType
Specifies a requested font smoothing type : gray or LCD.
|
private ReadOnlyDoubleWrapper |
height |
private static java.util.Map<java.lang.Object,java.lang.Integer> |
idMap |
private InputMethodClientImpl |
imClient |
private DoubleProperty |
maxHeight |
private DoubleProperty |
maxWidth |
private DoubleProperty |
minHeight |
private DoubleProperty |
minWidth |
private WebPage |
page |
private DoubleProperty |
prefHeight |
private DoubleProperty |
prefWidth |
private TKPulseListener |
stagePulseListener
The stage pulse listener registered with the toolkit.
|
private ReadOnlyDoubleWrapper |
width |
private static int |
WK_DND_ACTION_COPY |
private static int |
WK_DND_ACTION_LINK |
private static int |
WK_DND_ACTION_MOVE |
private static int |
WK_DND_ACTION_NONE |
private DoubleProperty |
zoom
Zoom factor applied to the whole page contents.
|
BASELINE_OFFSET_SAME_AS_HEIGHT
Constructor and Description |
---|
WebView()
Creates a
WebView object. |
Modifier and Type | Method and Description |
---|---|
BooleanProperty |
contextMenuEnabledProperty() |
DoubleProperty |
fontScaleProperty() |
ObjectProperty<FontSmoothingType> |
fontSmoothingTypeProperty() |
protected ObservableList<Node> |
getChildren()
Gets the list of children of this
Parent . |
static java.util.List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
java.util.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. |
WebEngine |
getEngine()
Returns the
WebEngine object. |
double |
getFontScale() |
FontSmoothingType |
getFontSmoothingType() |
private static TransferMode[] |
getFXDndAction(int wkDndAction) |
double |
getHeight()
Returns height of this
WebView . |
private InputMethodClientImpl |
getInputMethodClient() |
double |
getMaxHeight()
Returns maximum height.
|
double |
getMaxWidth()
Returns maximum width.
|
double |
getMinHeight()
Sets minimum height.
|
double |
getMinWidth()
Returns minimum width.
|
double |
getPrefHeight()
Returns preferred height.
|
double |
getPrefWidth()
Returns preferred width.
|
double |
getWidth()
Returns width of this
WebView . |
private static int |
getWKDndAction(TransferMode... tms) |
private static int |
getWKDndEventType(EventType et) |
double |
getZoom()
Returns current zoom factor applied to the whole page contents.
|
private void |
handleStagePulse() |
ReadOnlyDoubleProperty |
heightProperty()
Height of this
WebView . |
protected boolean |
impl_computeContains(double localX,
double localY)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
BaseBounds |
impl_computeGeomBounds(BaseBounds bounds,
BaseTransform tx)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
protected NGNode |
impl_createPeer()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
protected void |
impl_pickNodeLocal(PickRay pickRay,
PickResultChooser result)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
void |
impl_updatePeer()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
boolean |
isContextMenuEnabled() |
boolean |
isResizable()
Indicates whether this node is a type which can be resized by its parent.
|
private boolean |
isTreeReallyVisible() |
double |
maxHeight(double width)
Called during layout to determine the maximum height for this node.
|
DoubleProperty |
maxHeightProperty()
Maximum height property.
|
double |
maxWidth(double height)
Called during layout to determine the maximum width for this node.
|
DoubleProperty |
maxWidthProperty()
Maximum width property.
|
double |
minHeight(double width)
Called during layout to determine the minimum height for this node.
|
DoubleProperty |
minHeightProperty()
Minimum height property.
|
double |
minWidth(double height)
Called during layout to determine the minimum width for this node.
|
DoubleProperty |
minWidthProperty()
Minimum width property.
|
double |
prefHeight(double width)
Called during layout to determine the preferred height for this node.
|
DoubleProperty |
prefHeightProperty()
Preferred height property.
|
double |
prefWidth(double height)
Called during layout to determine the preferred width for this node.
|
DoubleProperty |
prefWidthProperty()
Preferred width property.
|
private void |
processInputMethodEvent(InputMethodEvent ie) |
private void |
processKeyEvent(KeyEvent ev) |
private void |
processMouseEvent(MouseEvent ev) |
private void |
processScrollEvent(ScrollEvent ev) |
private void |
registerEventHandlers() |
void |
resize(double width,
double height)
If the node is resizable, will set its layout bounds to the specified
width and height.
|
void |
setContextMenuEnabled(boolean value) |
void |
setFontScale(double value) |
void |
setFontSmoothingType(FontSmoothingType value) |
void |
setMaxHeight(double value)
Sets maximum height.
|
void |
setMaxSize(double maxWidth,
double maxHeight)
Convenience method for setting maximum width and height.
|
void |
setMaxWidth(double value)
Sets maximum width.
|
void |
setMinHeight(double value)
Sets minimum height.
|
void |
setMinSize(double minWidth,
double minHeight)
Convenience method for setting minimum width and height.
|
void |
setMinWidth(double value)
Sets minimum width.
|
void |
setPrefHeight(double value)
Sets preferred height.
|
void |
setPrefSize(double prefWidth,
double prefHeight)
Convenience method for setting preferred width and height.
|
void |
setPrefWidth(double value)
Sets preferred width.
|
void |
setZoom(double value)
Sets current zoom factor applied to the whole page contents.
|
ReadOnlyDoubleProperty |
widthProperty()
Width of this
WebView . |
DoubleProperty |
zoomProperty()
Returns zoom property object.
|
computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBaselineOffset, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processCSS, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, layoutChildren, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, 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, impl_clearDirty, impl_computeIntersects, impl_computeLayoutBounds, impl_cssGetCursorInitialValue, impl_cssGetFocusTraversableInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_notifyLayoutBoundsChanged, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, 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
private static final java.util.Map<java.lang.Object,java.lang.Integer> idMap
private static final boolean DEFAULT_CONTEXT_MENU_ENABLED
private static final FontSmoothingType DEFAULT_FONT_SMOOTHING_TYPE
private static final double DEFAULT_ZOOM
private static final double DEFAULT_FONT_SCALE
private static final double DEFAULT_MIN_WIDTH
private static final double DEFAULT_MIN_HEIGHT
private static final double DEFAULT_PREF_WIDTH
private static final double DEFAULT_PREF_HEIGHT
private static final double DEFAULT_MAX_WIDTH
private static final double DEFAULT_MAX_HEIGHT
private final WebPage page
private final WebEngine engine
private volatile InputMethodClientImpl imClient
private final TKPulseListener stagePulseListener
private final ReadOnlyDoubleWrapper width
private final ReadOnlyDoubleWrapper height
private DoubleProperty zoom
private DoubleProperty fontScale
private DoubleProperty minWidth
private DoubleProperty minHeight
private DoubleProperty prefWidth
private DoubleProperty prefHeight
private DoubleProperty maxWidth
private DoubleProperty maxHeight
private ObjectProperty<FontSmoothingType> fontSmoothingType
private BooleanProperty contextMenuEnabled
private static final int WK_DND_ACTION_NONE
private static final int WK_DND_ACTION_COPY
private static final int WK_DND_ACTION_MOVE
private static final int WK_DND_ACTION_LINK
public final WebEngine getEngine()
WebEngine
object.public final double getWidth()
WebView
.public ReadOnlyDoubleProperty widthProperty()
WebView
.public final double getHeight()
WebView
.public ReadOnlyDoubleProperty heightProperty()
WebView
.public final void setZoom(double value)
value
- zoom factor to be setzoomProperty()
,
getZoom()
public final double getZoom()
zoomProperty()
,
setZoom(double value)
public final DoubleProperty zoomProperty()
getZoom()
,
setZoom(double value)
public final void setFontScale(double value)
public final double getFontScale()
public DoubleProperty fontScaleProperty()
public boolean isResizable()
Node
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.
isResizable
in class Node
Node.getContentBias()
,
Node.minWidth(double)
,
Node.minHeight(double)
,
Node.prefWidth(double)
,
Node.prefHeight(double)
,
Node.maxWidth(double)
,
Node.maxHeight(double)
,
Node.resize(double, double)
,
Node.getLayoutBounds()
public void resize(double width, double height)
Node
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.
resize
in class Node
width
- the target layout bounds widthheight
- the target layout bounds heightNode.isResizable()
,
Node.getContentBias()
,
Node.autosize()
,
Node.minWidth(double)
,
Node.minHeight(double)
,
Node.prefWidth(double)
,
Node.prefHeight(double)
,
Node.maxWidth(double)
,
Node.maxHeight(double)
,
Node.getLayoutBounds()
public final double minWidth(double height)
minWidth
in class Parent
height
- the height that should be used if minimum width depends on itNode.isResizable()
,
Node.getContentBias()
public final double minHeight(double width)
minHeight
in class Parent
width
- the width that should be used if minimum height depends on itNode.isResizable()
,
Node.getContentBias()
public final double prefWidth(double height)
prefWidth
in class Parent
height
- the height that should be used if preferred width depends on itNode.isResizable()
,
Node.getContentBias()
,
Node.autosize()
public final double prefHeight(double width)
prefHeight
in class Parent
width
- the width that should be used if preferred height depends on itNode.getContentBias()
,
Node.autosize()
public final double maxWidth(double height)
maxWidth
in class Node
height
- the height that should be used if maximum width depends on itNode.isResizable()
,
Node.getContentBias()
public final double maxHeight(double width)
maxHeight
in class Node
width
- the width that should be used if maximum height depends on itNode.isResizable()
,
Node.getContentBias()
public DoubleProperty minWidthProperty()
public final void setMinWidth(double value)
public final double getMinWidth()
public DoubleProperty minHeightProperty()
public final void setMinHeight(double value)
public final double getMinHeight()
public void setMinSize(double minWidth, double minHeight)
public DoubleProperty prefWidthProperty()
public final void setPrefWidth(double value)
public final double getPrefWidth()
public DoubleProperty prefHeightProperty()
public final void setPrefHeight(double value)
public final double getPrefHeight()
public void setPrefSize(double prefWidth, double prefHeight)
public DoubleProperty maxWidthProperty()
public final void setMaxWidth(double value)
public final double getMaxWidth()
public DoubleProperty maxHeightProperty()
public final void setMaxHeight(double value)
public final double getMaxHeight()
public void setMaxSize(double maxWidth, double maxHeight)
public final void setFontSmoothingType(FontSmoothingType value)
public final FontSmoothingType getFontSmoothingType()
public final ObjectProperty<FontSmoothingType> fontSmoothingTypeProperty()
public final void setContextMenuEnabled(boolean value)
public final boolean isContextMenuEnabled()
public final BooleanProperty contextMenuEnabledProperty()
public static java.util.List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public java.util.List<CssMetaData<? extends Styleable,?>> getCssMetaData()
Node.getClassCssMetaData()
so that
a Node's CssMetaData can be accessed without the need for reflection.getCssMetaData
in interface Styleable
getCssMetaData
in class Node
private boolean isTreeReallyVisible()
private void handleStagePulse()
private void processMouseEvent(MouseEvent ev)
private void processScrollEvent(ScrollEvent ev)
private void processKeyEvent(KeyEvent ev)
private InputMethodClientImpl getInputMethodClient()
private void processInputMethodEvent(InputMethodEvent ie)
private static int getWKDndEventType(EventType et)
private static int getWKDndAction(TransferMode... tms)
private static TransferMode[] getFXDndAction(int wkDndAction)
private void registerEventHandlers()
@Deprecated protected void impl_pickNodeLocal(PickRay pickRay, PickResultChooser result)
Node
impl_pickNodeLocal
in class Parent
protected ObservableList<Node> getChildren()
Parent
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 showning (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.
getChildren
in class Parent
Parent
.@Deprecated protected NGNode impl_createPeer()
impl_createPeer
in class Parent
@Deprecated public BaseBounds impl_computeGeomBounds(BaseBounds bounds, BaseTransform tx)
Node
impl_computeGeomBounds
in class Parent
@Deprecated protected boolean impl_computeContains(double localX, double localY)
impl_computeContains
in class Parent
@Deprecated public void impl_updatePeer()
Node
impl_updatePeer
in class Parent