2012-03-28 51 views
2

我試圖使一個函數繪圖儀。在實現縮放(通過添加&刪除點) 縮小我嘗試刪除chart.Data中的第一個和最後一個元素。 無法刪除最後一個元素無法刪除ObservableList中的最後一個元素

inData.remove(inData.size()-1); 

我得到一個NullPointerException,當我使用inData.size()我得到完整的代碼http://pastebin.com/DbMV153n

java.lang.NullPointerException 
at javafx.scene.chart.AreaChart.dataItemRemoved(AreaChart.java:153) 
at javafx.scene.chart.XYChart.dataItemsChanged(XYChart.java:419) 
at javafx.scene.chart.XYChart.access$2600(XYChart.java:50) 
at javafx.scene.chart.XYChart$Series$1.onChanged(XYChart.java:1382) 
at com.sun.javafx.collections.ObservableListWrapper.callObservers(ObservableListWrapper.java:78) 
at com.sun.javafx.collections.ObservableListWrapper.remove(ObservableListWrapper.java:185) 
at debugPlotter$1.handle(debugPlotter.java:63) 
at debugPlotter$1.handle(debugPlotter.java:1) 
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:60) 
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:162) 
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:115) 
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38) 
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37) 
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92) 
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35) 
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92) 
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:47) 
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33) 
at javafx.event.Event.fireEvent(Event.java:171) 
at javafx.scene.Scene$KeyHandler.process(Scene.java:2938) 
at javafx.scene.Scene$KeyHandler.access$1700(Scene.java:2868) 
at javafx.scene.Scene.impl_processKeyEvent(Scene.java:1431) 
at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:1862) 
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:107) 
at com.sun.glass.ui.View.handleKeyEvent(View.java:280) 
at com.sun.glass.ui.View.notifyKey(View.java:577) 
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) 
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29) 
at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62) 
at java.lang.Thread.run(Unknown Source) 
+0

請發佈堆棧跟蹤,它會告訴我們'NullPointerExcepti正在被拋出。 – 2012-03-29 00:18:11

+0

@Steve Kuo它給了一個NullPointer,但刪除最後一個之前的點 – 2012-03-29 00:25:33

+1

我用LineChart替換AreaChart,使用inDate.size() - 1它沒有任何例外!!!!!!!!!!!!! – 2012-03-29 00:45:56

回答

相關問題