O'Reilly logo

JavaFX 1.2 Application Development Cookbook by Vladimir Vivien

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Drawing simple shapes

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 javafx.scene.shape package.

Getting ready

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.

How to do it...

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required