package javaapplication36; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Scene; import javafx.scene.chart.PieChart; import javafx.stage.Stage; public class NewClass extends Application { public static void main(String[] args) { launch(args); } protected PieChart createObject(double width, double height) { ObservableList data = FXCollections.observableArrayList(); for (int i = 0; i < 10; i++) { data.add(new PieChart.Data("Data item " + i, i * 100)); } PieChart chart = new PieChart(data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setLabelLineLength(0); chart.setTitle("PieChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; } @Override public void start(Stage stage) throws Exception { stage.setScene(new Scene(createObject(300, 300), 300, 300)); stage.show(); } }