JavaFX Arc create from Circle

Description

JavaFX Arc create from Circle

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class Main extends Application {
  @Override/*from  w  ww .  jav  a2  s .  c  o  m*/
  public void start(Stage primaryStage) {
    // Create a pane
    Pane pane = new Pane();

    Circle c = new Circle();
    c.setRadius(150);
    c.setStroke(Color.BLACK);
    c.setFill(Color.WHITE);

    Arc a = new Arc(c.getRadius(), 
        c.getRadius() * 1.30, 
        c.getRadius() / 2, 
        c.getRadius() / 4, 0, -180);
    a.setType(ArcType.OPEN);
    a.setFill(Color.WHITE);
    a.setStroke(Color.BLACK);

    // Place nodes in pane
    pane.getChildren().addAll(c, a);

    // Create a scene and place it in the stage
    Scene scene = new Scene(pane, 150, 200);
    primaryStage.setTitle("java2s.com");
    primaryStage.setScene(scene);
    primaryStage.show();
  }
}



PreviousNext

Related