JavaFX Ellipse create

Description

JavaFX Ellipse create

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.FlowPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Ellipse;
import javafx.stage.Stage;

public class Main extends Application {
  @Override//  www .j  a  v  a2s .  c o  m
  public void start(Stage primaryStage) {
    // Create a pane and set its properties
    FlowPane pane = new FlowPane();
    pane.setPadding(new Insets(11, 12, 13, 14));
    pane.setHgap(5);
    pane.setVgap(5);

    for (int i = 0; i < 16; i++) {
      // Create an ellipse and add it to pane
      Ellipse e1 = new Ellipse(200, 200, 
        15, 10);
      e1.setStroke(Color.color(Math.random(), Math.random(),
        Math.random()));
      e1.setFill(Color.WHITE);
      e1.setRotate(i * 180 / 16);
      pane.getChildren().add(e1);
    }
    

    Scene scene = new Scene(pane, 550, 120);
    primaryStage.setTitle("ShowFlowPane");
    primaryStage.setScene(scene);
    primaryStage.show();
  }
  

  public static void main(String[] args) {
    launch(args);
  }
}



PreviousNext

Related