I have, say 3 datasets in the plot, and from time to time, I need to add/remove them from the plot. It works fine with adding/removing the other two datasets, but whenever I try to remove the primary dataset, I get an NullPointerException as following:
Code: Select all
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.jfree.chart.plot.XYPlot.drawRangeGridlines(XYPlot.java:2791)
at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:2202)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1039)
at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1269)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Code: Select all
plot.setDataset(i, null);
plot.setRenderer(i, null);