package bugs; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.chart.PieChart; import javafx.scene.chart.PieChart.Data; import javafx.scene.control.Label; import javafx.scene.input.MouseEvent; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class RT22987 extends Application { @Override public void start(Stage primaryStage) throws Exception { ObservableList pieChartData = FXCollections.observableArrayList( new PieChart.Data("A", 20), new PieChart.Data("B", 12)); PieChart chart = new PieChart(pieChartData); chart.setPrefSize(600, 600); final Label pieLabel = new Label(); final Label posLabel = new Label(); VBox vbox = new VBox(5); vbox.getChildren().addAll(pieLabel, posLabel, chart); for (final Data data : pieChartData) { data.getNode().setPickOnBounds(false); data.getNode().setOnMouseEntered(new EventHandler() { public void handle(MouseEvent me) { pieLabel.setText("In " + data.getName()); } }); data.getNode().setOnMouseExited(new EventHandler() { public void handle(MouseEvent me) { pieLabel.setText(null); } }); data.getNode().setOnMouseClicked(new EventHandler() { public void handle(MouseEvent me) { pieLabel.setText(data.getName() + " clicked"); } }); } vbox.setOnMouseMoved(new EventHandler() { public void handle(MouseEvent me) { posLabel.textProperty().set(me.getSceneX() + " " + me.getSceneY()); } }); //vbox.getStylesheets().add(getClass().getResource("ui.css").toExternalForm()); primaryStage.setScene(new Scene(vbox)); primaryStage.show(); } public static void main(String[] args) { launch(args); } }