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? - UI controls
Another type of node is a set of built-in UI controls such as buttons, list views, and progress bars. These controls can be added to the graphical scene just like other nodes. See the topic How do I work with controls? - 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. - Layout nodes
Layout nodes are containers for content nodes that control how they are positioned in the scene. See the topic How do I lay out my UI page?
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. - Score Your Game
This blog uses a customized node to present fancy buttons on the JavaFX component that shows the score and enables its smooth changing.
API Documentation
Last Updated: November 2009
[Return to How-To's Home]
Do you have comments about this article? We welcome your participation in our community. Please keep your comments civil and on point. You may optionally provide your email address to be notified of repliesyour information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.