Java FX 2.0

Package javafx.scene

Provides the core set of base classes for the JavaFX Scene Graph API.

See: Description

Package javafx.scene Description

Provides the core set of base classes for the JavaFX Scene Graph API. A scene graph is a tree-like data structure, where each item in the tree has zero or one parent and zero or more children.

The two primary classes in this package are:

Branch nodes are of type Parent or subclasses thereof.

Leaf nodes are classes such as Rectangle, Text, ImageView, MediaView, or other such leaf classes which cannot have children.

A node may occur at most once anywhere in the scene graph. Specifically, a node must appear no more than once in the children list of a Parent or as the clip of a Node. See the Node class for more details on these restrictions.


An example JavaFX scene graph is as follows:

The above example will generate the following image:

Coordinate System and Transformations

The Node class defines a traditional computer graphics "local" coordinate system in which the x axis increases to the right and the y axis increases downwards. The concrete node classes for shapes provide variables for defining the geometry and location of the shape within this local coordinate space. For example, Rectangle provides x, y, width, height variables while Circle provides centerX, centerY, and radius.

Any Node can have transformations applied to it. These include translation, rotation, scaling, or shearing transformations. A transformation will change the position, orientation, or size of the coordinate system as viewed from the parent of the node that has been transformed.

See the Node class for more information on transformations.

Bounding Rectangle

Since every Node has transformations, every Node's geometric bounding rectangle can be described differently depending on whether transformations are accounted for or not.

Each Node has the following properties which specifies these bounding rectangles:

See the Node class for more information on bounding rectangles.


The JavaFX Scene Graph provides the facility to style nodes using CSS (Cascading Style Sheets). The Node class contains id, styleClass, and style variables are used by CSS selectors to find nodes to which styles should be applied. The Scene class contains the stylesheets variable which is a sequence of URLs that reference CSS style sheets that are to be applied to the nodes within that scene.

For further information about CSS, how to apply CSS styles to nodes, and what properties are available for styling, see the CSS Reference Guide.

Java FX 2.0

Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. - all specs in one place