Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Null pointer exception in JavaFX line chart

Tags:

javafx-2

I using a JavaFX LineChart in my Swing application and when try to clear the series data i get this exception.

My code just call the clear method, the call is made in the JavaFX thread using Platform.runLater, i using 1.7.0_09 on ubuntu, is there any problems with my code or is this a bug in JavaFX.

series.getData().clear();

series is an XYChart.Series object

Exception in runnable
java.lang.NullPointerException
at javafx.scene.chart.LineChart.dataItemRemoved(LineChart.java:275)
at javafx.scene.chart.XYChart.dataItemsChanged(XYChart.java:470)
at javafx.scene.chart.XYChart.access$2500(XYChart.java:72)
at javafx.scene.chart.XYChart$Series$1.onChanged(XYChart.java:1462)
at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:134)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:48)
at com.sun.javafx.collections.ObservableListWrapper.callObservers(ObservableListWrapper.java:97)
at com.sun.javafx.collections.ObservableListWrapper.clear(ObservableListWrapper.java:184)
like image 351
José Avatar asked Dec 07 '12 13:12

José


1 Answers

The problem is now solved, it seems it is a bug of JavaFX.

I have solved by adding

lineChart.setAnimated(false); and it all works fine. In JIRA Kenai it has been proposed as bug by commenting lineChart.setCreateSymbols(false);

This also works but I think it is not the right answer, I can use .setCreateSymbols(false) or (true) having setted setAnimated(false);

like image 73
Wiz Avatar answered Sep 21 '22 06:09

Wiz