In JavaFX, the origin is the upper left corner of the Scene with positive-x going to the right and positive-y going down.
Note that this coordinate system also means that rotations will be clockwise for positive angles and counter clockwise for negative angles.
You can add subclasses of the Shape class to your root node.
Useful Shape methods include:
setFill(Paint value)
setStroke(Paint value)
Shape objects also inherit many, many methods from Node. See the API for a particular Shape such as Circle or Rectangle.
Each Shape subclass has a different way of setting position and other measurements. For example, to place a circle, you would use setCenterX and setCenterY. See the API for the shape you are adding.
Placing Shapes in a Group node will respect positions, but Region nodes may use layout rules that ignore them. If your goal is to draw a freeform picture of Shapes, you should place your shapes in a Group node.
Sample code is given on the Java FX HW 1 lab page.
Last modified: February 27, 2023
Back to Javafx Overview