回答編集履歴

1

見直しキャンペーン中

2023/07/23 07:44

投稿

TN8001
TN8001

スコア9326

test CHANGED
@@ -1,77 +1,40 @@
1
1
  いろいろやり方はありますが、わかりやすそうなのはこうでしょうか。
2
2
 
3
-
4
-
5
3
  ```Java
6
-
7
4
  import javafx.application.Application;
8
-
9
5
  import javafx.collections.FXCollections;
10
-
11
6
  import javafx.collections.ObservableList;
12
-
13
7
  import javafx.scene.Group;
14
-
15
8
  import javafx.scene.Scene;
16
-
17
9
  import javafx.scene.chart.PieChart;
18
-
19
10
  import javafx.stage.Stage;
20
11
 
21
-
22
-
23
12
  public class PieChartSample extends Application {
24
-
25
13
  @Override
26
-
27
14
  public void start(Stage stage) {
28
-
29
15
  Scene scene = new Scene(new Group());
30
-
31
16
  stage.setTitle("Imported Fruits");
32
-
33
17
  stage.setWidth(500);
34
-
35
18
  stage.setHeight(500);
36
19
 
37
-
38
-
39
20
  ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
40
-
41
21
  int[] pa = new int[]{ 1, 2, 3 };
42
22
 
43
-
44
-
45
23
  for (int i = 0; i < pa.length; i++) {
46
-
47
24
  pieChartData.add(new PieChart.Data(Integer.toString(i), pa[i]));
48
-
49
25
  }
50
26
 
51
-
52
-
53
27
  final PieChart chart = new PieChart(pieChartData);
54
-
55
28
  chart.setTitle("Imported Fruits");
56
29
 
57
-
58
-
59
30
  ((Group) scene.getRoot()).getChildren().add(chart);
60
-
61
31
  stage.setScene(scene);
62
-
63
32
  stage.show();
64
-
65
33
  }
66
34
 
67
-
68
-
69
35
  public static void main(String[] args) {
70
-
71
36
  launch(args);
72
-
73
37
  }
74
-
75
38
  }
76
-
77
39
  ```
40
+ ![アプリ画像](https://ddjkaamml8q8x.cloudfront.net/questions/2023-07-23/b8764151-8ea3-4475-83d3-f746916f8e26.png)