The JavaFX application framework was designed from the ground up to handle graphical elements. JavaFX provides inherent support for basic geometrical shapes as a first-class API. This recipe shows how to programmatically draw lines, rectangles, circles, and ellipses using the
Shape APIs found in the
Before you can draw your shapes using JavaFX, you must know how to create a basic JavaFX application and know how to add content to the application's scene. To refresh your memory, see the first recipe of this chapter, Building a JavaFX application.
The following code snippet shows how to draw a line, a rectangle, a circle, and an ellipse on the screen. You can get the full ...