How-To's > How do I use nodes?


The objects that appear in the graphical scene of your application are all nodes. Nodes are descended from the javafx.scene.Node class. However, you do not use the Node class directly. Instead, you use classes that inherit from the Node class. You can use built-in nodes or create a custom node with the CustomNode class.

Built-in Nodes

The following types of nodes are available as classes in the JavaFX Script programming language:

  • Shapes
    Shapes such as rectangles, circles, lines, and polygons are all types of nodes. See the topic How do I work with shapes?
  • Text
    Text is also a node and can have the same effects, transformations, and animations applied to it as other nodes. See the topic How do I work with text? for more topics about creating and formatting text.
  • Graphics
    After graphics are loaded, they can be used similar to other nodes. See the topic How do I work with graphics?
  • Group node
    The Group class contains a set of child node objects. Group nodes are handy when you want to apply transforms, states, or effect to all objects within the group.

Because all types of nodes inherit from the javafx.scene.Node class, you can use variables and functions from the Node class for any of your nodes. For example, you can specify how opaque your node is by using the opacity variable. A set of variables is intended to define the behavior in response to mouse events that occured on your node such as onMouseClicked, onMouseDragged, onMouseEntered, onMouseMoved, and onMouseWheelPressed.

See the following tutorial for examples of creating nodes in a scene.

Custom Nodes

Alternatively, you can extend the CustomNode class to create a custom node with the content you need. See the following document for examples that extend the CustomNode class.

API Documentation

Last Updated: April 2010
[Return to How-To's Home]