JavaFX Ellipse set dashed line

Description

JavaFX Ellipse set dashed line

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Ellipse;
import javafx.stage.Stage;

public class Main extends Application {
  @Override//from   ww  w . ja v a  2  s .  c o  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);
    ellipse.getStrokeDashArray().addAll(6.0, 21.0);
      
    // Place nodes in pane
    pane.getChildren().addAll(ellipse);

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