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
TheGroupclass 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.
- Increasing Your Contacts With a Customized JavaFX Address Book
This sample creates a customized node calledContactNodeas an entry for an address book. - Getting Weather Forecast from Yahoo!
This sample broadly uses theCustomNodeclass to create customized nodes. - Easy Animations With the Animated Transitions
This article extends theCustomNodeclass to create an ImageView node to display images with a redefined mouse function that starts and pauses the animation.
API Documentation
Last Updated: April 2010
[Return to How-To's Home]