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.
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.
A Scene may be created and modified on any thread until it is attached
to a Window that is showing.
After that, it must be modified only on the JavaFX Application Thread.
Note that Scene is not thread-safe; modifying a Scene on
multiple threads at the same time will lead to unpredictable results and
must be avoided.
The JavaFX Application Thread is created as part of the startup process for
the JavaFX runtime. See the javafx. class and
the Platform#startup(Runnable) method for more information.
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);
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv static class | |
| private static enum | |
| pack-priv class | Scene.
A Drag and Drop gesture has a lifespan that lasts from mouse PRESSED event to mouse RELEASED event. |
| private static enum | Scene.
State of a drag gesture with regards to DRAG_DETECTED event. |
| pack-priv class | |
| pack-priv class | |
| pack-priv class | |
| private class | |
| private class | |
| private class | |
| pack-priv class | |
| pack-priv class | |
| public static interface | Scene.
Contains scene preferences that can override |
| pack-priv class | |
| private class | |
| pack-priv class | |
| private static class | |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private Accessible | |
| private Map | |
| private static boolean | |
| private final SceneAntialiasing | |
| private ObjectProperty | camera
Specifies the type of camera use for rendering this |
| private final Set | clearInitialCssStateNodes
A list of nodes that have expressed their interest to be notified when the next CSS pass is completed. |
| private Scene. | |
| private ObjectProperty | cursor
Defines the mouse cursor for this |
| private Point2D | |
| private Point2D | |
| private Camera | |
| private static final NodeOrientation | |
| private final boolean | |
| private EnumSet | |
| private Node[] | dirtyNodes
Set of dirty nodes; processed once per frame by the synchronizer. |
| private int | |
| pack-priv Scene. | |
| pack-priv Scene. | |
| private NodeOrientation | |
| private Scene. | |
| private ObjectProperty | eventDispatcher
Specifies the event dispatcher for this scene. |
| private ObjectProperty | fill
Defines the background fill of this |
| private boolean | focusDirty
Set to true if something has happened to the focused node that makes it no longer eligible to have the focus. |
| private Scene. | focusOwner
The scene's current focus owner node. |
| private ReadOnlyDoubleWrapper | height
The height of this |
| private double | |
| private static boolean | |
| private InputMethodStateManager | inputMethodStateManager
A non-popup scene creates a state manager to coordinate input method handling with popups. |
| private static boolean | |
| private SceneEventDispatcher | |
| private List | |
| private static final int | |
| private Scene. | |
| private TouchEvent | |
| private ObjectProperty | nodeOrientation
Node orientation describes the flow of visual data within a node. |
| pack-priv Parent | |
| private ObjectProperty | onContextMenuRequested
Defines a function to be called when a mouse button has been clicked
(pressed and released) on this |
| private ObjectProperty | onDragDetected
Defines a function to be called when drag gesture has been detected. |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | onInputMethodTextChanged
Defines a function to be called when this |
| private ObjectProperty | onKeyPressed
Defines a function to be called when some |
| private ObjectProperty | onKeyReleased
Defines a function to be called when some |
| private ObjectProperty | onKeyTyped
Defines a function to be called when some |
| private ObjectProperty | onMouseClicked
Defines a function to be called when a mouse button has been clicked
(pressed and released) on this |
| private ObjectProperty | onMouseDragEntered
Defines a function to be called when a full press-drag-release gesture
enters this |
| private ObjectProperty | onMouseDragExited
Defines a function to be called when a full press-drag-release gesture
exits this |
| private ObjectProperty | onMouseDragged
Defines a function to be called when a mouse button is pressed
on this |
| private ObjectProperty | onMouseDragOver
Defines a function to be called when a full press-drag-release gesture
progresses within this |
| private ObjectProperty | onMouseDragReleased
Defines a function to be called when a full press-drag-release gesture
ends within this |
| private ObjectProperty | onMouseEntered
Defines a function to be called when the mouse enters this |
| private ObjectProperty | onMouseExited
Defines a function to be called when the mouse exits this |
| private ObjectProperty | onMouseMoved
Defines a function to be called when mouse cursor moves within
this |
| private ObjectProperty | onMousePressed
Defines a function to be called when a mouse button
has been pressed on this |
| private ObjectProperty | onMouseReleased
Defines a function to be called when a mouse button
has been released on this |
| private ObjectProperty | onRotate
Defines a function to be called when user performs a rotating action. |
| private ObjectProperty | onRotationFinished
Defines a function to be called when a rotating gesture ends. |
| private ObjectProperty | onRotationStarted
Defines a function to be called when a rotating gesture is detected. |
| private ObjectProperty | onScroll
Defines a function to be called when user performs a scrolling action. |
| private ObjectProperty | onScrollFinished
Defines a function to be called when a scrolling gesture ends. |
| private ObjectProperty | onScrollStarted
Defines a function to be called when a scrolling gesture is detected. |
| private ObjectProperty | onSwipeDown
Defines a function to be called when an downward swipe gesture happens in this scene. |
| private ObjectProperty | onSwipeLeft
Defines a function to be called when an leftward swipe gesture happens in this scene. |
| private ObjectProperty | onSwipeRight
Defines a function to be called when an rightward swipe gesture happens in this scene. |
| private ObjectProperty | onSwipeUp
Defines a function to be called when an upward swipe gesture happens in this scene. |
| private ObjectProperty | onTouchMoved
Defines a function to be called when a touch point is moved. |
| private ObjectProperty | onTouchPressed
Defines a function to be called when a new touch point is pressed. |
| private ObjectProperty | onTouchReleased
Defines a function to be called when a new touch point is pressed. |
| private ObjectProperty | onTouchStationary
Defines a function to be called when a touch point stays pressed and still. |
| private ObjectProperty | onZoom
Defines a function to be called when user performs a zooming action. |
| private ObjectProperty | onZoomFinished
Defines a function to be called when a zooming gesture ends. |
| private ObjectProperty | onZoomStarted
Defines a function to be called when a zooming gesture is detected. |
| private TKScene | peer
The peer of this scene |
| private static int | |
| private static final boolean | PLATFORM_DRAG_GESTURE_INITIATION
If true, use the platform's drag gesture detection else use Scene-level detection as per DnDGesture.process(MouseEvent, List) |
| private List | |
| pack-priv final ScenePreferences | |
| private List | |
| private ObservableMap | |
| private ObjectProperty | root
Defines the root |
| private final Scene. | |
| pack-priv Scene. | scenePulseListener
The scene pulse listener that gets called on toolkit pulses |
| private final InvalidationListener | |
| private final Scene. | |
| private boolean | |
| private static TKPulseListener | |
| private static List | |
| private static List | |
| private static List | |
| private final ObservableList | stylesheets
A ObservableList of string URLs linking to the stylesheets to use with this scene's contents. |
| private final Scene. | |
| pack-priv Runnable | testPulseListener
A listener for pulses, used for testing. |
| private Scene. | |
| private int | |
| private Scene. | |
| private int | |
| private TouchPoint[] | |
| private Map | |
| private PerformanceTracker | |
| private static final Object | |
| private Node | transientFocusContainer
A node that is temporarily responsible for the FOCUS_NODE accessibility attribute. |
| private TopMostTraversalEngine | |
| private static final Object | |
| private ObjectProperty | |
| private ReadOnlyDoubleWrapper | width
The width of this |
| private double | |
| private ReadOnlyObjectWrapper | window
The |
| private boolean | windowFocused
Stores whether the window associated with this scene is currently focused. |
| private ReadOnlyDoubleWrapper | x
The horizontal location of this |
| private ReadOnlyDoubleWrapper | y
The vertical location of this |
| private final Scene. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public | |
| public | Scene(Parent
The root node of the scene graph root, double The width of the scene width, double The height of the scene height, boolean The depth buffer flag
depthBuffer)
The depthBuffer flag is a conditional feature and its default value is
false. See
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. |
| public | Scene(Parent
The root node of the scene graph root, double The width of the scene width, double The height of the scene height, boolean The depth buffer flag depthBuffer, SceneAntialiasing The scene anti-aliasing attribute. A value of
antiAliasing)null is treated as DISABLED.
The depthBuffer and antiAliasing are conditional features. With the
respective default values of: false and 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. |
| private | Scene(Parent root, double width, double height, Paint fill, boolean depthBuffer, SceneAntialiasing antiAliasing)
|
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public final <T extends Event> void | addEventFilter(final EventType<T> eventType, final EventHandler<? super T> eventFilter)
Overrides default javafx. Registers an event filter for this target. |
| public final <T extends Event> void | addEventHandler(final EventType<T> eventType, final EventHandler<? super T> eventHandler)
Overrides default javafx. Registers an event handler for this target. |
| pack-priv final void | |
| public void | |
| public final void | addPostLayoutPulseListener(Runnable
The Runnable to be called when the pulse occurs. r)Adds a new scene post layout pulse listener to this scene. |
| public final void | addPreLayoutPulseListener(Runnable
The Runnable to be called when the pulse occurs. r)Adds a new scene pre layout pulse listener to this scene. |
| pack-priv static void | |
| pack-priv void | |
| public EventDispatchChain | buildEventDispatchChain(EventDispatchChain tail)
Implements javafx. Construct an event dispatch chain for this target. |
| private NodeOrientation | |
| public final ObjectProperty | |
| private void | |
| pack-priv final void | |
| private SceneEventDispatcher | |
| public final ObjectProperty | |
| private void | |
| pack-priv void | |
| pack-priv void | |
| private void | |
| pack-priv void | |
| pack-priv static WritableImage | doSnapshot(Scene scene, SubScene subScene, double x, double y, double w, double h, Node root, BaseTransform transform, boolean depthBuffer, Paint fill, Camera camera, WritableImage wimg)
|
| private WritableImage | |
| public final ReadOnlyObjectProperty | Returns: the effective node orientation of this sceneThe effective node orientation of a scene resolves the inheritance of node orientation, returning either left-to-right or right-to-left. |
| pack-priv void | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| pack-priv void | |
| private void | |
| private void | |
| public final ReadOnlyObjectProperty | |
| pack-priv void | generateMouseExited(Node
Node which is going to be removed removing)Generates mouse exited event for a node which is going to be removed and its children, where appropriate. |
| public ObservableMap | |
| pack-priv Accessible | |
| public final SceneAntialiasing | Returns: the SceneAntialiasing for this sceneReturn the defined |
| private boolean | |
| public final Camera | |
| public final Cursor | |
| pack-priv Camera | |
| public final NodeOrientation | |
| public final EventDispatcher | |
| public final Paint | |
| public final Node | |
| public final double | |
| pack-priv InputMethodStateManager | |
| private SceneEventDispatcher | |
| public ObservableMap | |
| public final NodeOrientation | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| pack-priv TKScene | |
| public final Scene. | Returns: thePreferences instanceGets the scene preferences that can override |
| private static double | |
| private static double | |
| public final ObservableMap | Returns: an observable map of properties on this node for use primarily by application developersReturns an observable map of properties on this node for use primarily by application developers. |
| public final Parent | |
| public final ObservableList | Returns: the list of stylesheets to use with this sceneGets an observable list of string URLs linking to the stylesheets to use with this scene's contents. |
| public final String | Returns: The URL of the user-agent stylesheet that will be used by this Scene, or null if has not been set.Get the URL of the user-agent stylesheet that will be used by this Scene. |
| public Object | Returns: The Object that was previously set, or null if no property has been set or if null was set.Returns a previously set Object property, or null if no such property
has been set using the |
| public final double | |
| public final Window | |
| public final double | |
| public final double | |
| public boolean | |
| public final ReadOnlyDoubleProperty | |
| private ReadOnlyDoubleWrapper | |
| private void | |
| private void | |
| pack-priv final void | |
| pack-priv void | |
| public final boolean | Returns: the depth buffer attribute.Retrieves the depth buffer attribute for this scene. |
| pack-priv boolean | |
| private boolean | |
| private boolean | |
| pack-priv final boolean | |
| private boolean | |
| pack-priv static boolean | |
| pack-priv boolean | Returns: boolean indicating whether the scene is quiescentReturns true if this scene is quiescent, i.e. it has no activity pending on it such as CSS processing or layout requests. |
| public Node | |
| pack-priv void | |
| pack-priv void | |
| private void | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | Returns: the function to be called when this scene is a drag and drop gesture source after its data has been dropped on a drop targetDefines a function to be called when this |
| public final ObjectProperty | Returns: the function to be called when the mouse button is released on this scene during drag and drop gestureDefines a function to be called when the mouse button is released
on this |
| public final ObjectProperty | Returns: function to be called when drag gesture enters this sceneDefines a function to be called when drag gesture
enters this |
| public final ObjectProperty | Returns: the function to be called when drag gesture exits this sceneDefines a function to be called when drag gesture
exits this |
| public final ObjectProperty | Returns: the function to be called when drag gesture progresses within this sceneDefines a function to be called when drag gesture progresses
within this |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| private void | |
| private PickResult | |
| private void | |
| pack-priv void | |
| private void | |
| private void | |
| pack-priv boolean | |
| private boolean | |
| pack-priv void | |
| private void | |
| pack-priv void | |
| pack-priv Accessible | |
| public final <T extends Event> void | removeEventFilter(final EventType<T> eventType, final EventHandler<? super T> eventFilter)
Overrides default javafx. Unregisters a previously registered event filter from this target. |
| public final <T extends Event> void | removeEventHandler(final EventType<T> eventType, final EventHandler<? super T> eventHandler)
Overrides default javafx. Unregisters a previously registered event handler from this target. |
| pack-priv final void | |
| public void | |
| public final void | removePostLayoutPulseListener(Runnable
The Runnable that should no longer be called when the pulse
occurs for this scene. r)Removes a previously registered scene post layout pulse listener from listening to pulses in this scene. |
| public final void | removePreLayoutPulseListener(Runnable
The Runnable that should no longer be called when the pulse
occurs for this scene. r)Removes a previously registered scene pre layout pulse listener from listening to pulses in this scene. |
| pack-priv void | |
| pack-priv void | |
| pack-priv final void | |
| public final ObjectProperty | |
| private void | |
| pack-priv static void | |
| public final void | |
| public final void | |
| private void | |
| public final void | |
| protected final < the specific event class of the handler T extends Event> void | setEventHandler(final EventType<T>
the event type to associate with the given eventHandler eventType, final EventHandler<? super T> the handler to register, or null to unregister eventHandler)Sets the handler to use for this event type. |
| public final void | |
| pack-priv final void | |
| private void | |
| private final void | |
| pack-priv void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | setUserAgentStylesheet(String
the URL of the user-agent stylesheet 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. |
| public void | setUserData(Object
The value to be stored - this can later be retrieved by calling
value)Scene#getUserData().Convenience method for setting a single Object property that can be retrieved at a later date. |
| private final void | |
| pack-priv void | |
| private void | |
| private final void | |
| private final void | |
| public WritableImage | Returns: the rendered imagethe 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. image)Takes a snapshot of this scene and returns the rendered image when it is ready. |
| public void | snapshot(Callback<SnapshotResult, Void>
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. callback, WritableImage 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. image)Takes a snapshot of this scene at the next frame and calls the specified callback method when the image is ready. |
| public Dragboard | Returns: ADragboard to place this Scene's data onThe supported transferModes)TransferMode(s) of this NodeConfirms a potential drag and drop gesture that is recognized over this
|
| pack-priv Dragboard | |
| public void | |
| pack-priv void | |
| private void | |
| pack-priv Node | |
| pack-priv boolean | traverse(Node node, Direction dir, TraversalMethod method)
Traverses focus from the given node in the given direction. |
| pack-priv void | |
| public final ObjectProperty | Returns: the userAgentStylesheet propertyGets the userAgentStylesheet property. |
| public final ReadOnlyDoubleProperty | |
| private ReadOnlyDoubleWrapper | |
| private void | |
| public final ReadOnlyObjectProperty | |
| private ReadOnlyObjectWrapper | |
| public final ReadOnlyDoubleProperty | |
| private ReadOnlyDoubleWrapper | |
| public final ReadOnlyDoubleProperty | |
| private ReadOnlyDoubleWrapper |