JavaFX How to - Create an open arc with a fill








Question

We would like to know how to create an open arc with a fill.

Answer

//from   w  w w.ja va  2 s  .  co m
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.stage.Stage;

public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);
  }

  @Override
  public void start(Stage stage) {
    Arc arc = new Arc(0, 0, 50, 100, 0, 90);
    arc.setFill(Color.LIGHTGRAY);

    HBox box = new HBox(arc);
 
    Scene scene = new Scene(box);
    stage.setScene(scene);
    stage.setTitle("Test");
    stage.show();
  }
}