go to previous page   go to home page   go to next page highlighting

Answer:

rect.setStroke( Color.RED );
rect.setFill( Color.TRANSPARENT );

A Rectangle is a child of Shape and inherits these methods (and others.)

There are many choices in class Color. The color is part of the state of the Shape and may be changed after the object has been constructed.


Scene Graph

Scene Graph, a Group as root, a Rectangle as child

The job of a JavaFX Application is to build a scene graph, which the graphics system then renders (paints). The scene graph contains the graphics objects that go into the scene. The above program builds the above (not very complicated) scene graph.

(Confusion Alert !) This picture shows the objects in a scene graph that the program builds when it runs. It is not showing inheritance between classes.


QUESTION 4:

The Rectangle object is the only child of the root. Could another Rectangle object be added to the scene graph?


go to previous page   go to home page   go to next page