JavaFX: Creating A Circle

This entry is part 46 of 55 in the series JavaFX

In creating a JavaFX circle, we would usually use the constructor below.

Circle(double radius, Paint fill)

It is usually sufficed for us to only provide a radius and a color for the circle.

So in the example below, we are using

new Circle(150, Color.DARKKHAKI)

where 150 is the radius of the circle in pixel.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class DrawCircle extends Application {

    public void start(Stage stage) {
        StackPane root = new StackPane(new Circle(150, Color.DARKKHAKI));
        stage.setScene(new Scene(root, 500, 400));;

    public static void main(String... args) {





Series Navigation<< JavaFX: Inline statement and CSS ID
JavaFX: Setting absolute position for circle >>