1 import javafx.application.Application;
2 import javafx.scene.Scene;
3 import javafx.scene.layout.Pane;
4 import javafx.scene.paint.Color;
5 import javafx.stage.Stage;
6 import javafx.scene.shape.Ellipse;
7
8 public class ShowEllipse extends Application {
9 @Override
10 public void start(Stage primaryStage) {
11
12 Scene scene = new Scene(new MyEllipse(), 300, 200);
13 primaryStage.setTitle("ShowEllipse");
14 primaryStage.setScene(scene);
15 primaryStage.show();
16 }
17
18
22 public static void main(String[] args) {
23 launch(args);
24 }
25 }
26
27 class MyEllipse extends Pane {
28 private void paint() {
29 getChildren().clear();
30 for (int i = 0; i < 16; i++) {
31
32 Ellipse e1 = new Ellipse(getWidth() / 2, getHeight() / 2,
33 getWidth() / 2 - 50, getHeight() / 2 - 50);
34 e1.setStroke(Color.color(Math.random(), Math.random(),
35 Math.random()));
36 e1.setFill(Color.WHITE);
37 e1.setRotate(i * 180 / 16);
38 getChildren().add(e1);
39 }
40 }
41
42 @Override
43 public void setWidth(double width) {
44 super.setWidth(width);
45 paint();
46 }
47
48 @Override
49 public void setHeight(double height) {
50 super.setHeight(height);
51 paint();
52 }
53 }