JavaFX Arc create from Ellipse

Description

JavaFX Arc create from Ellipse

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.Ellipse;
import javafx.stage.Stage;

public class Main extends Application {
  @Override//www.  j  a  v a2  s.  co  m
  public void start(Stage primaryStage) {
    // Create a pane
    Pane pane = new Pane();

    // Create an ellipse and set its properties
    Ellipse ellipse = new Ellipse(75, 40, 50, 20);
    ellipse.setStroke(Color.BLACK);
    ellipse.setFill(Color.WHITE);
    
    Arc arc1 = new Arc(ellipse.getCenterX(), 150, ellipse.getRadiusX(), 
        ellipse.getRadiusY(), 0, -180);
    arc1.setType(ArcType.OPEN);
    arc1.setFill(Color.WHITE);
    arc1.setStroke(Color.BLACK);
      
    // Place nodes in pane
    pane.getChildren().addAll(ellipse,arc1);

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