@DefaultProperty(value="root") public class Scene extends Object implements EventTarget
Scene
class is the container for all content in a scene graph.
The background of the scene is filled as specified by the fill
property.
The application must specify the root Node
for the scene graph by setting
the root
property. If a Group
is used as the root, the
contents of the scene graph will be clipped by the scene's width and height and
changes to the scene's size (if user resizes the stage) will not alter the
layout of the scene graph. If a resizable node (layout Region
or
Control
is set as the root, then the root's size will track the
scene's size, causing the contents to be relayed out as necessary.
The scene's size may be initialized by the application during construction. If no size is specified, the scene will automatically compute its initial size based on the preferred size of its content. If only one dimension is specified, the other dimension is computed using the specified dimension, respecting content bias of a root.
An application may request depth buffer support or scene anti-aliasing
support at the creation of a Scene
. A scene with only 2D shapes and
without any 3D transforms does not need a depth buffer nor scene
anti-aliasing support. A scene containing 3D shapes or 2D shapes with 3D
transforms may use depth buffer support for proper depth sorted rendering; to
avoid depth fighting (also known as Z fighting), disable depth testing on 2D
shapes that have no 3D transforms. See
depthTest
for more information. A scene with
3D shapes may enable scene anti-aliasing to improve its rendering quality.
The depthBuffer and antiAliasing flags are conditional features. With the
respective default values of: false and SceneAntialiasing.DISABLED
.
See ConditionalFeature.SCENE3D
for more information.
A default headlight will be added to a scene that contains one or more
Shape3D
nodes, but no light nodes. This light source is a
Color.WHITE
PointLight
placed at the camera position.
Scene objects must be constructed and modified on the JavaFX Application Thread.
Example:
import javafx.scene.*; import javafx.scene.paint.*; import javafx.scene.shape.*; Group root = new Group(); Scene s = new Scene(root, 300, 300, Color.BLACK); Rectangle r = new Rectangle(25,25,250,250); r.setFill(Color.BLUE); root.getChildren().add(r);
Type | Property and Description |
---|---|
ObjectProperty<Camera> |
camera
Specifies the type of camera use for rendering this
Scene . |
ObjectProperty<Cursor> |
cursor
Defines the mouse cursor for this
Scene . |
ReadOnlyObjectProperty<NodeOrientation> |
effectiveNodeOrientation
The effective node orientation of a scene resolves the inheritance of
node orientation, returning either left-to-right or right-to-left.
|
ObjectProperty<EventDispatcher> |
eventDispatcher
Specifies the event dispatcher for this scene.
|
ObjectProperty<Paint> |
fill
Defines the background fill of this
Scene . |
ReadOnlyObjectProperty<Node> |
focusOwner
The scene's current focus owner node.
|
ReadOnlyDoubleProperty |
height
The height of this
Scene |
ObjectProperty<NodeOrientation> |
nodeOrientation
Property holding NodeOrientation.
|
ObjectProperty<EventHandler<? super ContextMenuEvent>> |
onContextMenuRequested
Defines a function to be called when a mouse button has been clicked
(pressed and released) on this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onDragDetected
Defines a function to be called when drag gesture has been
detected.
|
ObjectProperty<EventHandler<? super DragEvent>> |
onDragDone
Defines a function to be called when this @{code Scene} is a
drag and drop gesture source after its data has
been dropped on a drop target.
|
ObjectProperty<EventHandler<? super DragEvent>> |
onDragDropped
Defines a function to be called when the mouse button is released
on this
Scene during drag and drop gesture. |
ObjectProperty<EventHandler<? super DragEvent>> |
onDragEntered
Defines a function to be called when drag gesture
enters this
Scene . |
ObjectProperty<EventHandler<? super DragEvent>> |
onDragExited
Defines a function to be called when drag gesture
exits this
Scene . |
ObjectProperty<EventHandler<? super DragEvent>> |
onDragOver
Defines a function to be called when drag gesture progresses
within this
Scene . |
ObjectProperty<EventHandler<? super InputMethodEvent>> |
onInputMethodTextChanged
Defines a function to be called when this
Node
has input focus and the input method text has changed. |
ObjectProperty<EventHandler<? super KeyEvent>> |
onKeyPressed
Defines a function to be called when some
Node of this
Scene has input focus and a key has been pressed. |
ObjectProperty<EventHandler<? super KeyEvent>> |
onKeyReleased
Defines a function to be called when some
Node of this
Scene has input focus and a key has been released. |
ObjectProperty<EventHandler<? super KeyEvent>> |
onKeyTyped
Defines a function to be called when some
Node of this
Scene has input focus and a key has been typed. |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseClicked
Defines a function to be called when a mouse button has been clicked
(pressed and released) on this
Scene . |
ObjectProperty<EventHandler<? super MouseDragEvent>> |
onMouseDragEntered
Defines a function to be called when a full press-drag-release gesture
enters this
Scene . |
ObjectProperty<EventHandler<? super MouseDragEvent>> |
onMouseDragExited
Defines a function to be called when a full press-drag-release gesture
exits this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseDragged
Defines a function to be called when a mouse button is pressed
on this
Scene and then dragged. |
ObjectProperty<EventHandler<? super MouseDragEvent>> |
onMouseDragOver
Defines a function to be called when a full press-drag-release gesture
progresses within this
Scene . |
ObjectProperty<EventHandler<? super MouseDragEvent>> |
onMouseDragReleased
Defines a function to be called when a full press-drag-release gesture
ends within this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseEntered
Defines a function to be called when the mouse enters this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseExited
Defines a function to be called when the mouse exits this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseMoved
Defines a function to be called when mouse cursor moves within
this
Scene but no buttons have been pushed. |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMousePressed
Defines a function to be called when a mouse button
has been pressed on this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseReleased
Defines a function to be called when a mouse button
has been released on this
Scene . |
ObjectProperty<EventHandler<? super RotateEvent>> |
onRotate
Defines a function to be called when user performs a rotating action.
|
ObjectProperty<EventHandler<? super RotateEvent>> |
onRotationFinished
Defines a function to be called when a rotating gesture ends.
|
ObjectProperty<EventHandler<? super RotateEvent>> |
onRotationStarted
Defines a function to be called when a rotating gesture is detected.
|
ObjectProperty<EventHandler<? super ScrollEvent>> |
onScrollFinished
Defines a function to be called when a scrolling gesture ends.
|
ObjectProperty<EventHandler<? super ScrollEvent>> |
onScroll
Defines a function to be called when user performs a scrolling action.
|
ObjectProperty<EventHandler<? super ScrollEvent>> |
onScrollStarted
Defines a function to be called when a scrolling gesture is detected.
|
ObjectProperty<EventHandler<? super SwipeEvent>> |
onSwipeDown
Defines a function to be called when an downward swipe gesture
happens in this scene.
|
ObjectProperty<EventHandler<? super SwipeEvent>> |
onSwipeLeft
Defines a function to be called when an leftward swipe gesture
happens in this scene.
|
ObjectProperty<EventHandler<? super SwipeEvent>> |
onSwipeRight
Defines a function to be called when an rightward swipe gesture
happens in this scene.
|
ObjectProperty<EventHandler<? super SwipeEvent>> |
onSwipeUp
Defines a function to be called when an upward swipe gesture
happens in this scene.
|
ObjectProperty<EventHandler<? super TouchEvent>> |
onTouchMoved
Defines a function to be called when a touch point is moved.
|
ObjectProperty<EventHandler<? super TouchEvent>> |
onTouchPressed
Defines a function to be called when a new touch point is pressed.
|
ObjectProperty<EventHandler<? super TouchEvent>> |
onTouchReleased
Defines a function to be called when a new touch point is pressed.
|
ObjectProperty<EventHandler<? super TouchEvent>> |
onTouchStationary
Defines a function to be called when a touch point stays pressed and
still.
|
ObjectProperty<EventHandler<? super ZoomEvent>> |
onZoomFinished
Defines a function to be called when a zooming gesture ends.
|
ObjectProperty<EventHandler<? super ZoomEvent>> |
onZoom
Defines a function to be called when user performs a zooming action.
|
ObjectProperty<EventHandler<? super ZoomEvent>> |
onZoomStarted
Defines a function to be called when a zooming gesture is detected.
|
ObjectProperty<Parent> |
root
Defines the root
Node of the scene graph. |
ObjectProperty<String> |
userAgentStylesheet |
ReadOnlyDoubleProperty |
width
The width of this
Scene |
ReadOnlyObjectProperty<Window> |
window
The
Window for this Scene |
ReadOnlyDoubleProperty |
x
The horizontal location of this
Scene on the Window . |
ReadOnlyDoubleProperty |
y
The vertical location of this
Scene on the Window . |
Constructor and Description |
---|
Scene(Parent root)
Creates a Scene for a specific root Node.
|
Scene(Parent root,
double width,
double height)
Creates a Scene for a specific root Node with a specific size.
|
Scene(Parent root,
double width,
double height,
boolean depthBuffer)
Constructs a scene consisting of a root, with a dimension of width and
height, and specifies whether a depth buffer is created for this scene.
|
Scene(Parent root,
double width,
double height,
boolean depthBuffer,
SceneAntialiasing antiAliasing)
Constructs a scene consisting of a root, with a dimension of width and
height, specifies whether a depth buffer is created for this scene and
specifies whether scene anti-aliasing is requested.
|
Scene(Parent root,
double width,
double height,
Paint fill)
Creates a Scene for a specific root Node with a specific size and fill.
|
Scene(Parent root,
Paint fill)
Creates a Scene for a specific root Node with a fill.
|
Modifier and Type | Method and Description |
---|---|
<T extends Event> |
addEventFilter(EventType<T> eventType,
EventHandler<? super T> eventFilter)
Registers an event filter to this scene.
|
<T extends Event> |
addEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Registers an event handler to this scene.
|
void |
addMnemonic(Mnemonic m)
Registers the specified mnemonic.
|
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail)
Construct an event dispatch chain for this scene.
|
ObjectProperty<Camera> |
cameraProperty()
Specifies the type of camera use for rendering this
Scene . |
ObjectProperty<Cursor> |
cursorProperty()
Defines the mouse cursor for this
Scene . |
ReadOnlyObjectProperty<NodeOrientation> |
effectiveNodeOrientationProperty()
The effective node orientation of a scene resolves the inheritance of
node orientation, returning either left-to-right or right-to-left.
|
ObjectProperty<EventDispatcher> |
eventDispatcherProperty()
Specifies the event dispatcher for this scene.
|
ObjectProperty<Paint> |
fillProperty()
Defines the background fill of this
Scene . |
ReadOnlyObjectProperty<Node> |
focusOwnerProperty()
The scene's current focus owner node.
|
ObservableMap<KeyCombination,Runnable> |
getAccelerators()
Gets the list of accelerators for this
Scene . |
SceneAntialiasing |
getAntiAliasing()
Return the defined
SceneAntialiasing for this Scene . |
Camera |
getCamera()
Gets the value of the property camera.
|
Cursor |
getCursor()
Gets the value of the property cursor.
|
NodeOrientation |
getEffectiveNodeOrientation()
Gets the value of the property effectiveNodeOrientation.
|
EventDispatcher |
getEventDispatcher()
Gets the value of the property eventDispatcher.
|
Paint |
getFill()
Gets the value of the property fill.
|
Node |
getFocusOwner()
Gets the value of the property focusOwner.
|
double |
getHeight()
Gets the value of the property height.
|
ObservableMap<KeyCombination,ObservableList<Mnemonic>> |
getMnemonics()
Gets the list of mnemonics for this
Scene . |
NodeOrientation |
getNodeOrientation()
Gets the value of the property nodeOrientation.
|
EventHandler<? super ContextMenuEvent> |
getOnContextMenuRequested()
Gets the value of the property onContextMenuRequested.
|
EventHandler<? super MouseEvent> |
getOnDragDetected()
Gets the value of the property onDragDetected.
|
EventHandler<? super DragEvent> |
getOnDragDone()
Gets the value of the property onDragDone.
|
EventHandler<? super DragEvent> |
getOnDragDropped()
Gets the value of the property onDragDropped.
|
EventHandler<? super DragEvent> |
getOnDragEntered()
Gets the value of the property onDragEntered.
|
EventHandler<? super DragEvent> |
getOnDragExited()
Gets the value of the property onDragExited.
|
EventHandler<? super DragEvent> |
getOnDragOver()
Gets the value of the property onDragOver.
|
EventHandler<? super InputMethodEvent> |
getOnInputMethodTextChanged()
Gets the value of the property onInputMethodTextChanged.
|
EventHandler<? super KeyEvent> |
getOnKeyPressed()
Gets the value of the property onKeyPressed.
|
EventHandler<? super KeyEvent> |
getOnKeyReleased()
Gets the value of the property onKeyReleased.
|
EventHandler<? super KeyEvent> |
getOnKeyTyped()
Gets the value of the property onKeyTyped.
|
EventHandler<? super MouseEvent> |
getOnMouseClicked()
Gets the value of the property onMouseClicked.
|
EventHandler<? super MouseDragEvent> |
getOnMouseDragEntered()
Gets the value of the property onMouseDragEntered.
|
EventHandler<? super MouseDragEvent> |
getOnMouseDragExited()
Gets the value of the property onMouseDragExited.
|
EventHandler<? super MouseEvent> |
getOnMouseDragged()
Gets the value of the property onMouseDragged.
|
EventHandler<? super MouseDragEvent> |
getOnMouseDragOver()
Gets the value of the property onMouseDragOver.
|
EventHandler<? super MouseDragEvent> |
getOnMouseDragReleased()
Gets the value of the property onMouseDragReleased.
|
EventHandler<? super MouseEvent> |
getOnMouseEntered()
Gets the value of the property onMouseEntered.
|
EventHandler<? super MouseEvent> |
getOnMouseExited()
Gets the value of the property onMouseExited.
|
EventHandler<? super MouseEvent> |
getOnMouseMoved()
Gets the value of the property onMouseMoved.
|
EventHandler<? super MouseEvent> |
getOnMousePressed()
Gets the value of the property onMousePressed.
|
EventHandler<? super MouseEvent> |
getOnMouseReleased()
Gets the value of the property onMouseReleased.
|
EventHandler<? super RotateEvent> |
getOnRotate()
Gets the value of the property onRotate.
|
EventHandler<? super RotateEvent> |
getOnRotationFinished()
Gets the value of the property onRotationFinished.
|
EventHandler<? super RotateEvent> |
getOnRotationStarted()
Gets the value of the property onRotationStarted.
|
EventHandler<? super ScrollEvent> |
getOnScroll()
Gets the value of the property onScroll.
|
EventHandler<? super ScrollEvent> |
getOnScrollFinished()
Gets the value of the property onScrollFinished.
|
EventHandler<? super ScrollEvent> |
getOnScrollStarted()
Gets the value of the property onScrollStarted.
|
EventHandler<? super SwipeEvent> |
getOnSwipeDown()
Gets the value of the property onSwipeDown.
|
EventHandler<? super SwipeEvent> |
getOnSwipeLeft()
Gets the value of the property onSwipeLeft.
|
EventHandler<? super SwipeEvent> |
getOnSwipeRight()
Gets the value of the property onSwipeRight.
|
EventHandler<? super SwipeEvent> |
getOnSwipeUp()
Gets the value of the property onSwipeUp.
|
EventHandler<? super TouchEvent> |
getOnTouchMoved()
Gets the value of the property onTouchMoved.
|
EventHandler<? super TouchEvent> |
getOnTouchPressed()
Gets the value of the property onTouchPressed.
|
EventHandler<? super TouchEvent> |
getOnTouchReleased()
Gets the value of the property onTouchReleased.
|
EventHandler<? super TouchEvent> |
getOnTouchStationary()
Gets the value of the property onTouchStationary.
|
EventHandler<? super ZoomEvent> |
getOnZoom()
Gets the value of the property onZoom.
|
EventHandler<? super ZoomEvent> |
getOnZoomFinished()
Gets the value of the property onZoomFinished.
|
EventHandler<? super ZoomEvent> |
getOnZoomStarted()
Gets the value of the property onZoomStarted.
|
ObservableMap<Object,Object> |
getProperties()
Returns an observable map of properties on this node for use primarily
by application developers.
|
Parent |
getRoot()
Gets the value of the property root.
|
ObservableList<String> |
getStylesheets()
Gets an observable list of string URLs linking to the stylesheets to use
with this scene's contents.
|
String |
getUserAgentStylesheet()
Get the URL of the user-agent stylesheet that will be used by this Scene.
|
Object |
getUserData()
Returns a previously set Object property, or null if no such property
has been set using the
setUserData(java.lang.Object) method. |
double |
getWidth()
Gets the value of the property width.
|
Window |
getWindow()
Gets the value of the property window.
|
double |
getX()
Gets the value of the property x.
|
double |
getY()
Gets the value of the property y.
|
boolean |
hasProperties()
Tests if Scene has properties.
|
ReadOnlyDoubleProperty |
heightProperty()
The height of this
Scene |
boolean |
isDepthBuffer()
Retrieves the depth buffer attribute for this scene.
|
Node |
lookup(String selector)
Looks for any node within the scene graph based on the specified CSS selector.
|
ObjectProperty<NodeOrientation> |
nodeOrientationProperty()
Property holding NodeOrientation.
|
ObjectProperty<EventHandler<? super ContextMenuEvent>> |
onContextMenuRequestedProperty()
Defines a function to be called when a mouse button has been clicked
(pressed and released) on this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onDragDetectedProperty()
Defines a function to be called when drag gesture has been
detected.
|
ObjectProperty<EventHandler<? super DragEvent>> |
onDragDoneProperty()
Defines a function to be called when this @{code Scene} is a
drag and drop gesture source after its data has
been dropped on a drop target.
|
ObjectProperty<EventHandler<? super DragEvent>> |
onDragDroppedProperty()
Defines a function to be called when the mouse button is released
on this
Scene during drag and drop gesture. |
ObjectProperty<EventHandler<? super DragEvent>> |
onDragEnteredProperty()
Defines a function to be called when drag gesture
enters this
Scene . |
ObjectProperty<EventHandler<? super DragEvent>> |
onDragExitedProperty()
Defines a function to be called when drag gesture
exits this
Scene . |
ObjectProperty<EventHandler<? super DragEvent>> |
onDragOverProperty()
Defines a function to be called when drag gesture progresses
within this
Scene . |
ObjectProperty<EventHandler<? super InputMethodEvent>> |
onInputMethodTextChangedProperty()
Defines a function to be called when this
Node
has input focus and the input method text has changed. |
ObjectProperty<EventHandler<? super KeyEvent>> |
onKeyPressedProperty()
Defines a function to be called when some
Node of this
Scene has input focus and a key has been pressed. |
ObjectProperty<EventHandler<? super KeyEvent>> |
onKeyReleasedProperty()
Defines a function to be called when some
Node of this
Scene has input focus and a key has been released. |
ObjectProperty<EventHandler<? super KeyEvent>> |
onKeyTypedProperty()
Defines a function to be called when some
Node of this
Scene has input focus and a key has been typed. |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseClickedProperty()
Defines a function to be called when a mouse button has been clicked
(pressed and released) on this
Scene . |
ObjectProperty<EventHandler<? super MouseDragEvent>> |
onMouseDragEnteredProperty()
Defines a function to be called when a full press-drag-release gesture
enters this
Scene . |
ObjectProperty<EventHandler<? super MouseDragEvent>> |
onMouseDragExitedProperty()
Defines a function to be called when a full press-drag-release gesture
exits this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseDraggedProperty()
Defines a function to be called when a mouse button is pressed
on this
Scene and then dragged. |
ObjectProperty<EventHandler<? super MouseDragEvent>> |
onMouseDragOverProperty()
Defines a function to be called when a full press-drag-release gesture
progresses within this
Scene . |
ObjectProperty<EventHandler<? super MouseDragEvent>> |
onMouseDragReleasedProperty()
Defines a function to be called when a full press-drag-release gesture
ends within this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseEnteredProperty()
Defines a function to be called when the mouse enters this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseExitedProperty()
Defines a function to be called when the mouse exits this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseMovedProperty()
Defines a function to be called when mouse cursor moves within
this
Scene but no buttons have been pushed. |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMousePressedProperty()
Defines a function to be called when a mouse button
has been pressed on this
Scene . |
ObjectProperty<EventHandler<? super MouseEvent>> |
onMouseReleasedProperty()
Defines a function to be called when a mouse button
has been released on this
Scene . |
ObjectProperty<EventHandler<? super RotateEvent>> |
onRotateProperty()
Defines a function to be called when user performs a rotating action.
|
ObjectProperty<EventHandler<? super RotateEvent>> |
onRotationFinishedProperty()
Defines a function to be called when a rotating gesture ends.
|
ObjectProperty<EventHandler<? super RotateEvent>> |
onRotationStartedProperty()
Defines a function to be called when a rotating gesture is detected.
|
ObjectProperty<EventHandler<? super ScrollEvent>> |
onScrollFinishedProperty()
Defines a function to be called when a scrolling gesture ends.
|
ObjectProperty<EventHandler<? super ScrollEvent>> |
onScrollProperty()
Defines a function to be called when user performs a scrolling action.
|
ObjectProperty<EventHandler<? super ScrollEvent>> |
onScrollStartedProperty()
Defines a function to be called when a scrolling gesture is detected.
|
ObjectProperty<EventHandler<? super SwipeEvent>> |
onSwipeDownProperty()
Defines a function to be called when an downward swipe gesture
happens in this scene.
|
ObjectProperty<EventHandler<? super SwipeEvent>> |
onSwipeLeftProperty()
Defines a function to be called when an leftward swipe gesture
happens in this scene.
|
ObjectProperty<EventHandler<? super SwipeEvent>> |
onSwipeRightProperty()
Defines a function to be called when an rightward swipe gesture
happens in this scene.
|
ObjectProperty<EventHandler<? super SwipeEvent>> |
onSwipeUpProperty()
Defines a function to be called when an upward swipe gesture
happens in this scene.
|
ObjectProperty<EventHandler<? super TouchEvent>> |
onTouchMovedProperty()
Defines a function to be called when a touch point is moved.
|
ObjectProperty<EventHandler<? super TouchEvent>> |
onTouchPressedProperty()
Defines a function to be called when a new touch point is pressed.
|
ObjectProperty<EventHandler<? super TouchEvent>> |
onTouchReleasedProperty()
Defines a function to be called when a new touch point is pressed.
|
ObjectProperty<EventHandler<? super TouchEvent>> |
onTouchStationaryProperty()
Defines a function to be called when a touch point stays pressed and
still.
|
ObjectProperty<EventHandler<? super ZoomEvent>> |
onZoomFinishedProperty()
Defines a function to be called when a zooming gesture ends.
|
ObjectProperty<EventHandler<? super ZoomEvent>> |
onZoomProperty()
Defines a function to be called when user performs a zooming action.
|
ObjectProperty<EventHandler<? super ZoomEvent>> |
onZoomStartedProperty()
Defines a function to be called when a zooming gesture is detected.
|
<T extends Event> |
removeEventFilter(EventType<T> eventType,
EventHandler<? super T> eventFilter)
Unregisters a previously registered event filter from this scene.
|
<T extends Event> |
removeEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Unregisters a previously registered event handler from this scene.
|
void |
removeMnemonic(Mnemonic m)
Unregisters the specified mnemonic.
|
ObjectProperty<Parent> |
rootProperty()
Defines the root
Node of the scene graph. |
void |
setCamera(Camera value)
Sets the value of the property camera.
|
void |
setCursor(Cursor value)
Sets the value of the property cursor.
|
void |
setEventDispatcher(EventDispatcher value)
Sets the value of the property eventDispatcher.
|
protected <T extends Event> |
setEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Sets the handler to use for this event type.
|
void |
setFill(Paint value)
Sets the value of the property fill.
|
void |
setNodeOrientation(NodeOrientation orientation)
Sets the value of the property nodeOrientation.
|
void |
setOnContextMenuRequested(EventHandler<? super ContextMenuEvent> value)
Sets the value of the property onContextMenuRequested.
|
void |
setOnDragDetected(EventHandler<? super MouseEvent> value)
Sets the value of the property onDragDetected.
|
void |
setOnDragDone(EventHandler<? super DragEvent> value)
Sets the value of the property onDragDone.
|
void |
setOnDragDropped(EventHandler<? super DragEvent> value)
Sets the value of the property onDragDropped.
|
void |
setOnDragEntered(EventHandler<? super DragEvent> value)
Sets the value of the property onDragEntered.
|
void |
setOnDragExited(EventHandler<? super DragEvent> value)
Sets the value of the property onDragExited.
|
void |
setOnDragOver(EventHandler<? super DragEvent> value)
Sets the value of the property onDragOver.
|
void |
setOnInputMethodTextChanged(EventHandler<? super InputMethodEvent> value)
Sets the value of the property onInputMethodTextChanged.
|
void |
setOnKeyPressed(EventHandler<? super KeyEvent> value)
Sets the value of the property onKeyPressed.
|
void |
setOnKeyReleased(EventHandler<? super KeyEvent> value)
Sets the value of the property onKeyReleased.
|
void |
setOnKeyTyped(EventHandler<? super KeyEvent> value)
Sets the value of the property onKeyTyped.
|
void |
setOnMouseClicked(EventHandler<? super MouseEvent> value)
Sets the value of the property onMouseClicked.
|
void |
setOnMouseDragEntered(EventHandler<? super MouseDragEvent> value)
Sets the value of the property onMouseDragEntered.
|
void |
setOnMouseDragExited(EventHandler<? super MouseDragEvent> value)
Sets the value of the property onMouseDragExited.
|
void |
setOnMouseDragged(EventHandler<? super MouseEvent> value)
Sets the value of the property onMouseDragged.
|
void |
setOnMouseDragOver(EventHandler<? super MouseDragEvent> value)
Sets the value of the property onMouseDragOver.
|
void |
setOnMouseDragReleased(EventHandler<? super MouseDragEvent> value)
Sets the value of the property onMouseDragReleased.
|
void |
setOnMouseEntered(EventHandler<? super MouseEvent> value)
Sets the value of the property onMouseEntered.
|
void |
setOnMouseExited(EventHandler<? super MouseEvent> value)
Sets the value of the property onMouseExited.
|
void |
setOnMouseMoved(EventHandler<? super MouseEvent> value)
Sets the value of the property onMouseMoved.
|
void |
setOnMousePressed(EventHandler<? super MouseEvent> value)
Sets the value of the property onMousePressed.
|
void |
setOnMouseReleased(EventHandler<? super MouseEvent> value)
Sets the value of the property onMouseReleased.
|
void |
setOnRotate(EventHandler<? super RotateEvent> value)
Sets the value of the property onRotate.
|
void |
setOnRotationFinished(EventHandler<? super RotateEvent> value)
Sets the value of the property onRotationFinished.
|
void |
setOnRotationStarted(EventHandler<? super RotateEvent> value)
Sets the value of the property onRotationStarted.
|
void |
setOnScroll(EventHandler<? super ScrollEvent> value)
Sets the value of the property onScroll.
|
void |
setOnScrollFinished(EventHandler<? super ScrollEvent> value)
Sets the value of the property onScrollFinished.
|
void |
setOnScrollStarted(EventHandler<? super ScrollEvent> value)
Sets the value of the property onScrollStarted.
|
void |
setOnSwipeDown(EventHandler<? super SwipeEvent> value)
Sets the value of the property onSwipeDown.
|
void |
setOnSwipeLeft(EventHandler<? super SwipeEvent> value)
Sets the value of the property onSwipeLeft.
|
void |
setOnSwipeRight(EventHandler<? super SwipeEvent> value)
Sets the value of the property onSwipeRight.
|
void |
setOnSwipeUp(EventHandler<? super SwipeEvent> value)
Sets the value of the property onSwipeUp.
|
void |
setOnTouchMoved(EventHandler<? super TouchEvent> value)
Sets the value of the property onTouchMoved.
|
void |
setOnTouchPressed(EventHandler<? super TouchEvent> value)
Sets the value of the property onTouchPressed.
|
void |
setOnTouchReleased(EventHandler<? super TouchEvent> value)
Sets the value of the property onTouchReleased.
|
void |
setOnTouchStationary(EventHandler<? super TouchEvent> value)
Sets the value of the property onTouchStationary.
|
void |
setOnZoom(EventHandler<? super ZoomEvent> value)
Sets the value of the property onZoom.
|
void |
setOnZoomFinished(EventHandler<? super ZoomEvent> value)
Sets the value of the property onZoomFinished.
|
void |
setOnZoomStarted(EventHandler<? super ZoomEvent> value)
Sets the value of the property onZoomStarted.
|
void |
setRoot(Parent value)
Sets the value of the property root.
|
void |
setUserAgentStylesheet(String url)
Set the URL of the user-agent stylesheet that will be used by this Scene in place of the
the platform-default user-agent stylesheet.
|
void |
setUserData(Object value)
Convenience method for setting a single Object property that can be
retrieved at a later date.
|
void |
snapshot(Callback<SnapshotResult,Void> callback,
WritableImage image)
Takes a snapshot of this scene at the next frame and calls the
specified callback method when the image is ready.
|
WritableImage |
snapshot(WritableImage image)
Takes a snapshot of this scene and returns the rendered image when
it is ready.
|
Dragboard |
startDragAndDrop(TransferMode... transferModes)
Confirms a potential drag and drop gesture that is recognized over this
Scene . |
void |
startFullDrag()
Starts a full press-drag-release gesture with this scene as gesture
source.
|
ObjectProperty<String> |
userAgentStylesheetProperty() |
ReadOnlyDoubleProperty |
widthProperty()
The width of this
Scene |
ReadOnlyObjectProperty<Window> |
windowProperty()
The
Window for this Scene |
ReadOnlyDoubleProperty |
xProperty()
The horizontal location of this
Scene on the Window . |
ReadOnlyDoubleProperty |
yProperty()
The vertical location of this
Scene on the Window . |
public final ReadOnlyObjectProperty<Window> windowProperty
Window
for this Scene
getWindow()
public final ReadOnlyDoubleProperty xProperty
Scene
on the Window
.getX()
public final ReadOnlyDoubleProperty yProperty
Scene
on the Window
.getY()
public final ReadOnlyDoubleProperty widthProperty
Scene
getWidth()
public final ReadOnlyDoubleProperty heightProperty
Scene
getHeight()
public final ObjectProperty<Camera> cameraProperty
Scene
.
If camera
is null, a parallel camera is used for rendering.
It is illegal to set a camera that belongs to other Scene
or SubScene
.
Note: this is a conditional feature. See
ConditionalFeature.SCENE3D
for more information.
getCamera()
,
setCamera(Camera)
public final ObjectProperty<Paint> fillProperty
Scene
. Both a null
value meaning 'paint no background' and a Paint
with transparency are supported. The default fill of the Scene is
Color.WHITE
, but it is more commonly the case that the initial
color shown to users is the background fill of the
root node
of the Scene
, as it typically is
stretched to take up all available space in the Scene
. The
root node of the Scene
is given the CSS style class 'root', and
the default user agent stylesheets that ship with JavaFX (presently
Caspian and Modena) apply styling on to this root style class. In the
case of Caspian this does not impact the background fill color of the
root node, but in the case of Modena the default fill is set to be a
light gray color.getFill()
,
setFill(Paint)
public final ObjectProperty<Parent> rootProperty
Node
of the scene graph.
If a Group
is used as the root, the
contents of the scene graph will be clipped by the scene's width and height and
changes to the scene's size (if user resizes the stage) will not alter the
layout of the scene graph. If a resizable node (layout Region
or
Control
) is set as the root, then the root's size will track the
scene's size, causing the contents to be relayed out as necessary.
Scene doesn't accept null root.getRoot()
,
setRoot(Parent)
public final ObjectProperty<Cursor> cursorProperty
Scene
.getCursor()
,
setCursor(Cursor)
public final ObjectProperty<String> userAgentStylesheetProperty
getUserAgentStylesheet()
,
setUserAgentStylesheet(String)
public final ReadOnlyObjectProperty<Node> focusOwnerProperty
getFocusOwner()
public final ObjectProperty<EventDispatcher> eventDispatcherProperty
EventDispatcher
, the new dispatcher should forward
events to the replaced dispatcher to keep the scene's default event
handling behavior.public final ObjectProperty<EventHandler<? super ContextMenuEvent>> onContextMenuRequestedProperty
Scene
.getOnContextMenuRequested()
,
setOnContextMenuRequested(EventHandler)
public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseClickedProperty
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseDraggedProperty
Scene
and then dragged.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseEnteredProperty
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseExitedProperty
Scene
.getOnMouseExited()
,
setOnMouseExited(EventHandler)
public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseMovedProperty
Scene
but no buttons have been pushed.getOnMouseMoved()
,
setOnMouseMoved(EventHandler)
public final ObjectProperty<EventHandler<? super MouseEvent>> onMousePressedProperty
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseReleasedProperty
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onDragDetectedProperty
public final ObjectProperty<EventHandler<? super MouseDragEvent>> onMouseDragOverProperty
Scene
.getOnMouseDragOver()
,
setOnMouseDragOver(EventHandler)
public final ObjectProperty<EventHandler<? super MouseDragEvent>> onMouseDragReleasedProperty
Scene
.getOnMouseDragReleased()
,
setOnMouseDragReleased(EventHandler)
public final ObjectProperty<EventHandler<? super MouseDragEvent>> onMouseDragEnteredProperty
Scene
.getOnMouseDragEntered()
,
setOnMouseDragEntered(EventHandler)
public final ObjectProperty<EventHandler<? super MouseDragEvent>> onMouseDragExitedProperty
Scene
.getOnMouseDragExited()
,
setOnMouseDragExited(EventHandler)
public final ObjectProperty<EventHandler<? super ScrollEvent>> onScrollStartedProperty
getOnScrollStarted()
,
setOnScrollStarted(EventHandler)
public final ObjectProperty<EventHandler<? super ScrollEvent>> onScrollProperty
getOnScroll()
,
setOnScroll(EventHandler)
public final ObjectProperty<EventHandler<? super ScrollEvent>> onScrollFinishedProperty
getOnScrollFinished()
,
setOnScrollFinished(EventHandler)
public final ObjectProperty<EventHandler<? super RotateEvent>> onRotationStartedProperty
getOnRotationStarted()
,
setOnRotationStarted(EventHandler)
public final ObjectProperty<EventHandler<? super RotateEvent>> onRotateProperty
getOnRotate()
,
setOnRotate(EventHandler)
public final ObjectProperty<EventHandler<? super RotateEvent>> onRotationFinishedProperty
getOnRotationFinished()
,
setOnRotationFinished(EventHandler)
public final ObjectProperty<EventHandler<? super ZoomEvent>> onZoomStartedProperty
getOnZoomStarted()
,
setOnZoomStarted(EventHandler)
public final ObjectProperty<EventHandler<? super ZoomEvent>> onZoomProperty
getOnZoom()
,
setOnZoom(EventHandler)
public final ObjectProperty<EventHandler<? super ZoomEvent>> onZoomFinishedProperty
getOnZoomFinished()
,
setOnZoomFinished(EventHandler)
public final ObjectProperty<EventHandler<? super SwipeEvent>> onSwipeUpProperty
getOnSwipeUp()
,
setOnSwipeUp(EventHandler)
public final ObjectProperty<EventHandler<? super SwipeEvent>> onSwipeDownProperty
getOnSwipeDown()
,
setOnSwipeDown(EventHandler)
public final ObjectProperty<EventHandler<? super SwipeEvent>> onSwipeLeftProperty
getOnSwipeLeft()
,
setOnSwipeLeft(EventHandler)
public final ObjectProperty<EventHandler<? super SwipeEvent>> onSwipeRightProperty
getOnSwipeRight()
,
setOnSwipeRight(EventHandler)
public final ObjectProperty<EventHandler<? super TouchEvent>> onTouchPressedProperty
getOnTouchPressed()
,
setOnTouchPressed(EventHandler)
public final ObjectProperty<EventHandler<? super TouchEvent>> onTouchMovedProperty
getOnTouchMoved()
,
setOnTouchMoved(EventHandler)
public final ObjectProperty<EventHandler<? super TouchEvent>> onTouchReleasedProperty
getOnTouchReleased()
,
setOnTouchReleased(EventHandler)
public final ObjectProperty<EventHandler<? super TouchEvent>> onTouchStationaryProperty
getOnTouchStationary()
,
setOnTouchStationary(EventHandler)
public final ObjectProperty<EventHandler<? super DragEvent>> onDragEnteredProperty
Scene
.public final ObjectProperty<EventHandler<? super DragEvent>> onDragExitedProperty
Scene
.getOnDragExited()
,
setOnDragExited(EventHandler)
public final ObjectProperty<EventHandler<? super DragEvent>> onDragOverProperty
Scene
.getOnDragOver()
,
setOnDragOver(EventHandler)
public final ObjectProperty<EventHandler<? super DragEvent>> onDragDroppedProperty
Scene
during drag and drop gesture. Transfer of data from
the DragEvent
's dragboard
should
happen in this function.getOnDragDropped()
,
setOnDragDropped(EventHandler)
public final ObjectProperty<EventHandler<? super DragEvent>> onDragDoneProperty
transferMode
of the
event shows what just happened at the drop target.
If transferMode
has the value MOVE
, then the source can
clear out its data. Clearing the source's data gives the appropriate
appearance to a user that the data has been moved by the drag and drop
gesture. A transferMode
that has the value NONE
indicates that no data was transferred during the drag and drop gesture.
Positional data for the DragEvent
is invalid. Valid positional
data for the DragEvent
is presented in the onDragDropped
event handler.getOnDragDone()
,
setOnDragDone(EventHandler)
public final ObjectProperty<EventHandler<? super KeyEvent>> onKeyPressedProperty
Node
of this
Scene
has input focus and a key has been pressed. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.getOnKeyPressed()
,
setOnKeyPressed(EventHandler)
public final ObjectProperty<EventHandler<? super KeyEvent>> onKeyReleasedProperty
Node
of this
Scene
has input focus and a key has been released. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.getOnKeyReleased()
,
setOnKeyReleased(EventHandler)
public final ObjectProperty<EventHandler<? super KeyEvent>> onKeyTypedProperty
Node
of this
Scene
has input focus and a key has been typed. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.getOnKeyTyped()
,
setOnKeyTyped(EventHandler)
public final ObjectProperty<EventHandler<? super InputMethodEvent>> onInputMethodTextChangedProperty
Node
has input focus and the input method text has changed. If this
function is not defined in this Node
, then it
receives the result string of the input method composition as a
series of onKeyTyped
function calls.
When the Node
loses the input focus, the JavaFX runtime
automatically commits the existing composed text if any.public final ObjectProperty<NodeOrientation> nodeOrientationProperty
Node orientation describes the flow of visual data within a node. In the English speaking world, visual data normally flows from left-to-right. In an Arabic or Hebrew world, visual data flows from right-to-left. This is consistent with the reading order of text in both worlds. The default value is left-to-right.
getNodeOrientation()
,
setNodeOrientation(NodeOrientation)
public final ReadOnlyObjectProperty<NodeOrientation> effectiveNodeOrientationProperty
getEffectiveNodeOrientation()
public Scene(Parent root)
root
- The root node of the scene graphNullPointerException
- if root is nullpublic Scene(Parent root, double width, double height)
root
- The root node of the scene graphwidth
- The width of the sceneheight
- The height of the sceneNullPointerException
- if root is nullpublic Scene(Parent root, Paint fill)
root
- The parentfill
- The fillNullPointerException
- if root is nullpublic Scene(Parent root, double width, double height, Paint fill)
root
- The root node of the scene graphwidth
- The width of the sceneheight
- The height of the scenefill
- The fillNullPointerException
- if root is nullpublic Scene(Parent root, double width, double height, boolean depthBuffer)
A scene with only 2D shapes and without any 3D transforms does not need a
depth buffer. A scene containing 3D shapes or 2D shapes with 3D
transforms may use depth buffer support for proper depth sorted
rendering; to avoid depth fighting (also known as Z fighting), disable
depth testing on 2D shapes that have no 3D transforms. See
depthTest
for more information.
root
- The root node of the scene graphwidth
- The width of the sceneheight
- The height of the scenedepthBuffer
- The depth buffer flag
The depthBuffer flag is a conditional feature and its default value is
false. See
ConditionalFeature.SCENE3D
for more information.
NullPointerException
- if root is nullNode.setDepthTest(DepthTest)
public Scene(Parent root, double width, double height, boolean depthBuffer, SceneAntialiasing antiAliasing)
A scene with only 2D shapes and without any 3D transforms does not need a
depth buffer nor scene anti-aliasing support. A scene containing 3D
shapes or 2D shapes with 3D transforms may use depth buffer support for
proper depth sorted rendering; to avoid depth fighting (also known as Z
fighting), disable depth testing on 2D shapes that have no 3D transforms.
See depthTest
for more information. A
scene with 3D shapes may enable scene anti-aliasing to improve its
rendering quality.
A Scene can be created and modified on any thread until it is attached to a Window
that is showing
(Window.isShowing()
. This does not mean the Scene is thread-safe,
so manipulation from multiple threads at the same time is illegal, may lead to unexpected results and must be avoided.
root
- The root node of the scene graphwidth
- The width of the sceneheight
- The height of the scenedepthBuffer
- The depth buffer flagantiAliasing
- The scene anti-aliasing attribute. A value of
null
is treated as DISABLED.
The depthBuffer and antiAliasing are conditional features. With the
respective default values of: false and SceneAntialiasing.DISABLED
. See
ConditionalFeature.SCENE3D
for more information.
NullPointerException
- if root is nullNode.setDepthTest(DepthTest)
public final SceneAntialiasing getAntiAliasing()
SceneAntialiasing
for this Scene
.
Note: this is a conditional feature. See
ConditionalFeature.SCENE3D
and SceneAntialiasing
for more information.
public final Window getWindow()
Window
for this Scene
public final ReadOnlyObjectProperty<Window> windowProperty()
Window
for this Scene
getWindow()
public final double getX()
Scene
on the Window
.public final ReadOnlyDoubleProperty xProperty()
Scene
on the Window
.getX()
public final double getY()
Scene
on the Window
.public final ReadOnlyDoubleProperty yProperty()
Scene
on the Window
.getY()
public final double getWidth()
Scene
public final ReadOnlyDoubleProperty widthProperty()
Scene
getWidth()
public final double getHeight()
Scene
public final ReadOnlyDoubleProperty heightProperty()
Scene
getHeight()
public final void setCamera(Camera value)
Scene
.
If camera
is null, a parallel camera is used for rendering.
It is illegal to set a camera that belongs to other Scene
or SubScene
.
Note: this is a conditional feature. See
ConditionalFeature.SCENE3D
for more information.
public final Camera getCamera()
Scene
.
If camera
is null, a parallel camera is used for rendering.
It is illegal to set a camera that belongs to other Scene
or SubScene
.
Note: this is a conditional feature. See
ConditionalFeature.SCENE3D
for more information.
public final ObjectProperty<Camera> cameraProperty()
Scene
.
If camera
is null, a parallel camera is used for rendering.
It is illegal to set a camera that belongs to other Scene
or SubScene
.
Note: this is a conditional feature. See
ConditionalFeature.SCENE3D
for more information.
getCamera()
,
setCamera(Camera)
public final void setFill(Paint value)
Scene
. Both a null
value meaning 'paint no background' and a Paint
with transparency are supported. The default fill of the Scene is
Color.WHITE
, but it is more commonly the case that the initial
color shown to users is the background fill of the
root node
of the Scene
, as it typically is
stretched to take up all available space in the Scene
. The
root node of the Scene
is given the CSS style class 'root', and
the default user agent stylesheets that ship with JavaFX (presently
Caspian and Modena) apply styling on to this root style class. In the
case of Caspian this does not impact the background fill color of the
root node, but in the case of Modena the default fill is set to be a
light gray color.public final Paint getFill()
Scene
. Both a null
value meaning 'paint no background' and a Paint
with transparency are supported. The default fill of the Scene is
Color.WHITE
, but it is more commonly the case that the initial
color shown to users is the background fill of the
root node
of the Scene
, as it typically is
stretched to take up all available space in the Scene
. The
root node of the Scene
is given the CSS style class 'root', and
the default user agent stylesheets that ship with JavaFX (presently
Caspian and Modena) apply styling on to this root style class. In the
case of Caspian this does not impact the background fill color of the
root node, but in the case of Modena the default fill is set to be a
light gray color.public final ObjectProperty<Paint> fillProperty()
Scene
. Both a null
value meaning 'paint no background' and a Paint
with transparency are supported. The default fill of the Scene is
Color.WHITE
, but it is more commonly the case that the initial
color shown to users is the background fill of the
root node
of the Scene
, as it typically is
stretched to take up all available space in the Scene
. The
root node of the Scene
is given the CSS style class 'root', and
the default user agent stylesheets that ship with JavaFX (presently
Caspian and Modena) apply styling on to this root style class. In the
case of Caspian this does not impact the background fill color of the
root node, but in the case of Modena the default fill is set to be a
light gray color.getFill()
,
setFill(Paint)
public final void setRoot(Parent value)
Node
of the scene graph.
If a Group
is used as the root, the
contents of the scene graph will be clipped by the scene's width and height and
changes to the scene's size (if user resizes the stage) will not alter the
layout of the scene graph. If a resizable node (layout Region
or
Control
) is set as the root, then the root's size will track the
scene's size, causing the contents to be relayed out as necessary.
Scene doesn't accept null root.public final Parent getRoot()
Node
of the scene graph.
If a Group
is used as the root, the
contents of the scene graph will be clipped by the scene's width and height and
changes to the scene's size (if user resizes the stage) will not alter the
layout of the scene graph. If a resizable node (layout Region
or
Control
) is set as the root, then the root's size will track the
scene's size, causing the contents to be relayed out as necessary.
Scene doesn't accept null root.public final ObjectProperty<Parent> rootProperty()
Node
of the scene graph.
If a Group
is used as the root, the
contents of the scene graph will be clipped by the scene's width and height and
changes to the scene's size (if user resizes the stage) will not alter the
layout of the scene graph. If a resizable node (layout Region
or
Control
) is set as the root, then the root's size will track the
scene's size, causing the contents to be relayed out as necessary.
Scene doesn't accept null root.getRoot()
,
setRoot(Parent)
public WritableImage snapshot(WritableImage image)
Paint
of this scene. The nodes in the scene are then rendered to the image.
The point (0,0) in scene coordinates is mapped to (0,0) in the image.
If the image is smaller than the size of the scene, then the rendering
will be clipped by the image.
When taking a snapshot of a scene that is being animated, either explicitly by the application or implicitly (such as chart animation), the snapshot will be rendered based on the state of the scene graph at the moment the snapshot is taken and will not reflect any subsequent animation changes.
image
- the writable image that will be used to hold the rendered scene.
It may be null in which case a new WritableImage will be constructed.
If the image is non-null, the scene will be rendered into the
existing image.
In this case, the width and height of the image determine the area
that is rendered instead of the width and height of the scene.IllegalStateException
- if this method is called on a thread
other than the JavaFX Application Thread.public void snapshot(Callback<SnapshotResult,Void> callback, WritableImage image)
Paint
of this scene. The nodes in the scene are then rendered to the image.
The point (0,0) in scene coordinates is mapped to (0,0) in the image.
If the image is smaller than the size of the scene, then the rendering
will be clipped by the image.
This is an asynchronous call, which means that other events or animation might be processed before the scene is rendered. If any such events modify a node in the scene that modification will be reflected in the rendered image (as it will also be reflected in the frame rendered to the Stage).
When taking a snapshot of a scene that is being animated, either explicitly by the application or implicitly (such as chart animation), the snapshot will be rendered based on the state of the scene graph at the moment the snapshot is taken and will not reflect any subsequent animation changes.
callback
- a class whose call method will be called when the image
is ready. The SnapshotResult that is passed into the call method of
the callback will contain the rendered image and the source scene
that was rendered. The callback parameter must not be null.image
- the writable image that will be used to hold the rendered scene.
It may be null in which case a new WritableImage will be constructed.
If the image is non-null, the scene will be rendered into the
existing image.
In this case, the width and height of the image determine the area
that is rendered instead of the width and height of the scene.IllegalStateException
- if this method is called on a thread
other than the JavaFX Application Thread.NullPointerException
- if the callback parameter is null.public final void setCursor(Cursor value)
Scene
.public final Cursor getCursor()
Scene
.public final ObjectProperty<Cursor> cursorProperty()
Scene
.getCursor()
,
setCursor(Cursor)
public Node lookup(String selector)
selector
- The css selector to look upNode
in the scene which matches the CSS selector
,
or null
if none is found.public final ObservableList<String> getStylesheets()
The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.
package com.example.javafx.app;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MyApp extends Application {
@Override public void start(Stage stage) {
Scene scene = new Scene(new Group());
scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
For additional information about using CSS with the scene graph,
see the CSS Reference Guide.public final ObjectProperty<String> userAgentStylesheetProperty()
getUserAgentStylesheet()
,
setUserAgentStylesheet(String)
public final String getUserAgentStylesheet()
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
public final void setUserAgentStylesheet(String url)
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
url
- The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL
does not have a [scheme:] component, the URL is considered to be the [path] component only.
Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to
the root of the application's classpath.public final boolean isDepthBuffer()
public final Node getFocusOwner()
public final ReadOnlyObjectProperty<Node> focusOwnerProperty()
getFocusOwner()
public final void setEventDispatcher(EventDispatcher value)
EventDispatcher
, the new dispatcher should forward
events to the replaced dispatcher to keep the scene's default event
handling behavior.public final EventDispatcher getEventDispatcher()
EventDispatcher
, the new dispatcher should forward
events to the replaced dispatcher to keep the scene's default event
handling behavior.public final ObjectProperty<EventDispatcher> eventDispatcherProperty()
EventDispatcher
, the new dispatcher should forward
events to the replaced dispatcher to keep the scene's default event
handling behavior.public final <T extends Event> void addEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
Event
of the specified type during the bubbling
phase of event delivery.T
- the specific event class of the handlereventType
- the type of the events to receive by the handlereventHandler
- the handler to registerNullPointerException
- if the event type or handler is nullpublic final <T extends Event> void removeEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
T
- the specific event class of the handlereventType
- the event type from which to unregistereventHandler
- the handler to unregisterNullPointerException
- if the event type or handler is nullpublic final <T extends Event> void addEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter)
Event
of the specified type during the
capturing phase of event delivery.T
- the specific event class of the filtereventType
- the type of the events to receive by the filtereventFilter
- the filter to registerNullPointerException
- if the event type or filter is nullpublic final <T extends Event> void removeEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter)
T
- the specific event class of the filtereventType
- the event type from which to unregistereventFilter
- the filter to unregisterNullPointerException
- if the event type or filter is nullprotected final <T extends Event> void setEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
T
- the specific event class of the handlereventType
- the event type to associate with the given eventHandlereventHandler
- the handler to register, or null to unregisterNullPointerException
- if the event type is nullpublic void addMnemonic(Mnemonic m)
m
- The mnemonicpublic void removeMnemonic(Mnemonic m)
m
- The mnemonicpublic ObservableMap<KeyCombination,ObservableList<Mnemonic>> getMnemonics()
Scene
.public ObservableMap<KeyCombination,Runnable> getAccelerators()
Scene
.public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail)
buildEventDispatchChain
in interface EventTarget
tail
- the initial chain to build frompublic final void setOnContextMenuRequested(EventHandler<? super ContextMenuEvent> value)
Scene
.public final EventHandler<? super ContextMenuEvent> getOnContextMenuRequested()
Scene
.public final ObjectProperty<EventHandler<? super ContextMenuEvent>> onContextMenuRequestedProperty()
Scene
.getOnContextMenuRequested()
,
setOnContextMenuRequested(EventHandler)
public final void setOnMouseClicked(EventHandler<? super MouseEvent> value)
Scene
.public final EventHandler<? super MouseEvent> getOnMouseClicked()
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseClickedProperty()
Scene
.public final void setOnMouseDragged(EventHandler<? super MouseEvent> value)
Scene
and then dragged.public final EventHandler<? super MouseEvent> getOnMouseDragged()
Scene
and then dragged.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseDraggedProperty()
Scene
and then dragged.public final void setOnMouseEntered(EventHandler<? super MouseEvent> value)
Scene
.public final EventHandler<? super MouseEvent> getOnMouseEntered()
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseEnteredProperty()
Scene
.public final void setOnMouseExited(EventHandler<? super MouseEvent> value)
Scene
.public final EventHandler<? super MouseEvent> getOnMouseExited()
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseExitedProperty()
Scene
.getOnMouseExited()
,
setOnMouseExited(EventHandler)
public final void setOnMouseMoved(EventHandler<? super MouseEvent> value)
Scene
but no buttons have been pushed.public final EventHandler<? super MouseEvent> getOnMouseMoved()
Scene
but no buttons have been pushed.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseMovedProperty()
Scene
but no buttons have been pushed.getOnMouseMoved()
,
setOnMouseMoved(EventHandler)
public final void setOnMousePressed(EventHandler<? super MouseEvent> value)
Scene
.public final EventHandler<? super MouseEvent> getOnMousePressed()
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onMousePressedProperty()
Scene
.public final void setOnMouseReleased(EventHandler<? super MouseEvent> value)
Scene
.public final EventHandler<? super MouseEvent> getOnMouseReleased()
Scene
.public final ObjectProperty<EventHandler<? super MouseEvent>> onMouseReleasedProperty()
Scene
.public final void setOnDragDetected(EventHandler<? super MouseEvent> value)
public final EventHandler<? super MouseEvent> getOnDragDetected()
public final ObjectProperty<EventHandler<? super MouseEvent>> onDragDetectedProperty()
public final void setOnMouseDragOver(EventHandler<? super MouseDragEvent> value)
Scene
.public final EventHandler<? super MouseDragEvent> getOnMouseDragOver()
Scene
.public final ObjectProperty<EventHandler<? super MouseDragEvent>> onMouseDragOverProperty()
Scene
.getOnMouseDragOver()
,
setOnMouseDragOver(EventHandler)
public final void setOnMouseDragReleased(EventHandler<? super MouseDragEvent> value)
Scene
.public final EventHandler<? super MouseDragEvent> getOnMouseDragReleased()
Scene
.public final ObjectProperty<EventHandler<? super MouseDragEvent>> onMouseDragReleasedProperty()
Scene
.getOnMouseDragReleased()
,
setOnMouseDragReleased(EventHandler)
public final void setOnMouseDragEntered(EventHandler<? super MouseDragEvent> value)
Scene
.public final EventHandler<? super MouseDragEvent> getOnMouseDragEntered()
Scene
.public final ObjectProperty<EventHandler<? super MouseDragEvent>> onMouseDragEnteredProperty()
Scene
.getOnMouseDragEntered()
,
setOnMouseDragEntered(EventHandler)
public final void setOnMouseDragExited(EventHandler<? super MouseDragEvent> value)
Scene
.public final EventHandler<? super MouseDragEvent> getOnMouseDragExited()
Scene
.public final ObjectProperty<EventHandler<? super MouseDragEvent>> onMouseDragExitedProperty()
Scene
.getOnMouseDragExited()
,
setOnMouseDragExited(EventHandler)
public final void setOnScrollStarted(EventHandler<? super ScrollEvent> value)
public final EventHandler<? super ScrollEvent> getOnScrollStarted()
public final ObjectProperty<EventHandler<? super ScrollEvent>> onScrollStartedProperty()
getOnScrollStarted()
,
setOnScrollStarted(EventHandler)
public final void setOnScroll(EventHandler<? super ScrollEvent> value)
public final EventHandler<? super ScrollEvent> getOnScroll()
public final ObjectProperty<EventHandler<? super ScrollEvent>> onScrollProperty()
getOnScroll()
,
setOnScroll(EventHandler)
public final void setOnScrollFinished(EventHandler<? super ScrollEvent> value)
public final EventHandler<? super ScrollEvent> getOnScrollFinished()
public final ObjectProperty<EventHandler<? super ScrollEvent>> onScrollFinishedProperty()
getOnScrollFinished()
,
setOnScrollFinished(EventHandler)
public final void setOnRotationStarted(EventHandler<? super RotateEvent> value)
public final EventHandler<? super RotateEvent> getOnRotationStarted()
public final ObjectProperty<EventHandler<? super RotateEvent>> onRotationStartedProperty()
getOnRotationStarted()
,
setOnRotationStarted(EventHandler)
public final void setOnRotate(EventHandler<? super RotateEvent> value)
public final EventHandler<? super RotateEvent> getOnRotate()
public final ObjectProperty<EventHandler<? super RotateEvent>> onRotateProperty()
getOnRotate()
,
setOnRotate(EventHandler)
public final void setOnRotationFinished(EventHandler<? super RotateEvent> value)
public final EventHandler<? super RotateEvent> getOnRotationFinished()
public final ObjectProperty<EventHandler<? super RotateEvent>> onRotationFinishedProperty()
getOnRotationFinished()
,
setOnRotationFinished(EventHandler)
public final void setOnZoomStarted(EventHandler<? super ZoomEvent> value)
public final EventHandler<? super ZoomEvent> getOnZoomStarted()
public final ObjectProperty<EventHandler<? super ZoomEvent>> onZoomStartedProperty()
getOnZoomStarted()
,
setOnZoomStarted(EventHandler)
public final void setOnZoom(EventHandler<? super ZoomEvent> value)
public final EventHandler<? super ZoomEvent> getOnZoom()
public final ObjectProperty<EventHandler<? super ZoomEvent>> onZoomProperty()
getOnZoom()
,
setOnZoom(EventHandler)
public final void setOnZoomFinished(EventHandler<? super ZoomEvent> value)
public final EventHandler<? super ZoomEvent> getOnZoomFinished()
public final ObjectProperty<EventHandler<? super ZoomEvent>> onZoomFinishedProperty()
getOnZoomFinished()
,
setOnZoomFinished(EventHandler)
public final void setOnSwipeUp(EventHandler<? super SwipeEvent> value)
public final EventHandler<? super SwipeEvent> getOnSwipeUp()
public final ObjectProperty<EventHandler<? super SwipeEvent>> onSwipeUpProperty()
getOnSwipeUp()
,
setOnSwipeUp(EventHandler)
public final void setOnSwipeDown(EventHandler<? super SwipeEvent> value)
public final EventHandler<? super SwipeEvent> getOnSwipeDown()
public final ObjectProperty<EventHandler<? super SwipeEvent>> onSwipeDownProperty()
getOnSwipeDown()
,
setOnSwipeDown(EventHandler)
public final void setOnSwipeLeft(EventHandler<? super SwipeEvent> value)
public final EventHandler<? super SwipeEvent> getOnSwipeLeft()
public final ObjectProperty<EventHandler<? super SwipeEvent>> onSwipeLeftProperty()
getOnSwipeLeft()
,
setOnSwipeLeft(EventHandler)
public final void setOnSwipeRight(EventHandler<? super SwipeEvent> value)
public final EventHandler<? super SwipeEvent> getOnSwipeRight()
public final ObjectProperty<EventHandler<? super SwipeEvent>> onSwipeRightProperty()
getOnSwipeRight()
,
setOnSwipeRight(EventHandler)
public final void setOnTouchPressed(EventHandler<? super TouchEvent> value)
public final EventHandler<? super TouchEvent> getOnTouchPressed()
public final ObjectProperty<EventHandler<? super TouchEvent>> onTouchPressedProperty()
getOnTouchPressed()
,
setOnTouchPressed(EventHandler)
public final void setOnTouchMoved(EventHandler<? super TouchEvent> value)
public final EventHandler<? super TouchEvent> getOnTouchMoved()
public final ObjectProperty<EventHandler<? super TouchEvent>> onTouchMovedProperty()
getOnTouchMoved()
,
setOnTouchMoved(EventHandler)
public final void setOnTouchReleased(EventHandler<? super TouchEvent> value)
public final EventHandler<? super TouchEvent> getOnTouchReleased()
public final ObjectProperty<EventHandler<? super TouchEvent>> onTouchReleasedProperty()
getOnTouchReleased()
,
setOnTouchReleased(EventHandler)
public final void setOnTouchStationary(EventHandler<? super TouchEvent> value)
public final EventHandler<? super TouchEvent> getOnTouchStationary()
public final ObjectProperty<EventHandler<? super TouchEvent>> onTouchStationaryProperty()
getOnTouchStationary()
,
setOnTouchStationary(EventHandler)
public final void setOnDragEntered(EventHandler<? super DragEvent> value)
public final EventHandler<? super DragEvent> getOnDragEntered()
public final ObjectProperty<EventHandler<? super DragEvent>> onDragEnteredProperty()
Scene
.public final void setOnDragExited(EventHandler<? super DragEvent> value)
Scene
.public final EventHandler<? super DragEvent> getOnDragExited()
Scene
.public final ObjectProperty<EventHandler<? super DragEvent>> onDragExitedProperty()
Scene
.getOnDragExited()
,
setOnDragExited(EventHandler)
public final void setOnDragOver(EventHandler<? super DragEvent> value)
Scene
.public final EventHandler<? super DragEvent> getOnDragOver()
Scene
.public final ObjectProperty<EventHandler<? super DragEvent>> onDragOverProperty()
Scene
.getOnDragOver()
,
setOnDragOver(EventHandler)
public final void setOnDragDropped(EventHandler<? super DragEvent> value)
public final EventHandler<? super DragEvent> getOnDragDropped()
public final ObjectProperty<EventHandler<? super DragEvent>> onDragDroppedProperty()
Scene
during drag and drop gesture. Transfer of data from
the DragEvent
's dragboard
should
happen in this function.getOnDragDropped()
,
setOnDragDropped(EventHandler)
public final void setOnDragDone(EventHandler<? super DragEvent> value)
transferMode
of the
event shows what just happened at the drop target.
If transferMode
has the value MOVE
, then the source can
clear out its data. Clearing the source's data gives the appropriate
appearance to a user that the data has been moved by the drag and drop
gesture. A transferMode
that has the value NONE
indicates that no data was transferred during the drag and drop gesture.
Positional data for the DragEvent
is invalid. Valid positional
data for the DragEvent
is presented in the onDragDropped
event handler.public final EventHandler<? super DragEvent> getOnDragDone()
transferMode
of the
event shows what just happened at the drop target.
If transferMode
has the value MOVE
, then the source can
clear out its data. Clearing the source's data gives the appropriate
appearance to a user that the data has been moved by the drag and drop
gesture. A transferMode
that has the value NONE
indicates that no data was transferred during the drag and drop gesture.
Positional data for the DragEvent
is invalid. Valid positional
data for the DragEvent
is presented in the onDragDropped
event handler.public final ObjectProperty<EventHandler<? super DragEvent>> onDragDoneProperty()
transferMode
of the
event shows what just happened at the drop target.
If transferMode
has the value MOVE
, then the source can
clear out its data. Clearing the source's data gives the appropriate
appearance to a user that the data has been moved by the drag and drop
gesture. A transferMode
that has the value NONE
indicates that no data was transferred during the drag and drop gesture.
Positional data for the DragEvent
is invalid. Valid positional
data for the DragEvent
is presented in the onDragDropped
event handler.getOnDragDone()
,
setOnDragDone(EventHandler)
public Dragboard startDragAndDrop(TransferMode... transferModes)
Scene
.
Can be called only from a DRAG_DETECTED event handler. The returned
Dragboard
is used to transfer data during
the drag and drop gesture. Placing this Scene
's data on the
Dragboard
also identifies this Scene
as the source of
the drag and drop gesture.
More detail about drag and drop gestures is described in the overivew
of DragEvent
.transferModes
- The supported TransferMode
(s) of this Node
Dragboard
to place this Scene
's data onIllegalStateException
- if drag and drop cannot be started at this
moment (it's called outside of DRAG_DETECTED
event handling).DragEvent
public void startFullDrag()
DRAG_DETECTED
mouse
event handler. More detail about dragging gestures can be found
in the overview of MouseEvent
and MouseDragEvent
.IllegalStateException
- if the full press-drag-release gesture
cannot be started at this moment (it's called outside of
DRAG_DETECTED
event handling).MouseEvent
,
MouseDragEvent
public final void setOnKeyPressed(EventHandler<? super KeyEvent> value)
Node
of this
Scene
has input focus and a key has been pressed. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.public final EventHandler<? super KeyEvent> getOnKeyPressed()
Node
of this
Scene
has input focus and a key has been pressed. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.public final ObjectProperty<EventHandler<? super KeyEvent>> onKeyPressedProperty()
Node
of this
Scene
has input focus and a key has been pressed. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.getOnKeyPressed()
,
setOnKeyPressed(EventHandler)
public final void setOnKeyReleased(EventHandler<? super KeyEvent> value)
Node
of this
Scene
has input focus and a key has been released. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.public final EventHandler<? super KeyEvent> getOnKeyReleased()
Node
of this
Scene
has input focus and a key has been released. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.public final ObjectProperty<EventHandler<? super KeyEvent>> onKeyReleasedProperty()
Node
of this
Scene
has input focus and a key has been released. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.getOnKeyReleased()
,
setOnKeyReleased(EventHandler)
public final void setOnKeyTyped(EventHandler<? super KeyEvent> value)
Node
of this
Scene
has input focus and a key has been typed. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.public final EventHandler<? super KeyEvent> getOnKeyTyped()
Node
of this
Scene
has input focus and a key has been typed. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.public final ObjectProperty<EventHandler<? super KeyEvent>> onKeyTypedProperty()
Node
of this
Scene
has input focus and a key has been typed. The function
is called only if the event hasn't been already consumed during its
capturing or bubbling phase.getOnKeyTyped()
,
setOnKeyTyped(EventHandler)
public final void setOnInputMethodTextChanged(EventHandler<? super InputMethodEvent> value)
Node
has input focus and the input method text has changed. If this
function is not defined in this Node
, then it
receives the result string of the input method composition as a
series of onKeyTyped
function calls.
When the Node
loses the input focus, the JavaFX runtime
automatically commits the existing composed text if any.public final EventHandler<? super InputMethodEvent> getOnInputMethodTextChanged()
Node
has input focus and the input method text has changed. If this
function is not defined in this Node
, then it
receives the result string of the input method composition as a
series of onKeyTyped
function calls.
When the Node
loses the input focus, the JavaFX runtime
automatically commits the existing composed text if any.public final ObjectProperty<EventHandler<? super InputMethodEvent>> onInputMethodTextChangedProperty()
Node
has input focus and the input method text has changed. If this
function is not defined in this Node
, then it
receives the result string of the input method composition as a
series of onKeyTyped
function calls.
When the Node
loses the input focus, the JavaFX runtime
automatically commits the existing composed text if any.public final ObservableMap<Object,Object> getProperties()
public boolean hasProperties()
public void setUserData(Object value)
getUserData()
.value
- The value to be stored - this can later be retrieved by calling
getUserData()
.public Object getUserData()
setUserData(java.lang.Object)
method.public final void setNodeOrientation(NodeOrientation orientation)
Node orientation describes the flow of visual data within a node. In the English speaking world, visual data normally flows from left-to-right. In an Arabic or Hebrew world, visual data flows from right-to-left. This is consistent with the reading order of text in both worlds. The default value is left-to-right.
public final NodeOrientation getNodeOrientation()
Node orientation describes the flow of visual data within a node. In the English speaking world, visual data normally flows from left-to-right. In an Arabic or Hebrew world, visual data flows from right-to-left. This is consistent with the reading order of text in both worlds. The default value is left-to-right.
public final ObjectProperty<NodeOrientation> nodeOrientationProperty()
Node orientation describes the flow of visual data within a node. In the English speaking world, visual data normally flows from left-to-right. In an Arabic or Hebrew world, visual data flows from right-to-left. This is consistent with the reading order of text in both worlds. The default value is left-to-right.
getNodeOrientation()
,
setNodeOrientation(NodeOrientation)
public final NodeOrientation getEffectiveNodeOrientation()
public final ReadOnlyObjectProperty<NodeOrientation> effectiveNodeOrientationProperty()
getEffectiveNodeOrientation()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.