Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

I'm getting the following error after compiling my code:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at ex12.LineDrawingFrame.paint(LineDrawingFrame.java:51)

at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)

at sun.awt.RepaintArea.paint(RepaintArea.java:224)

at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:630)

at java.awt.Component.dispatchEventImpl(Component.java:4031)

at java.awt.Container.dispatchEventImpl(Container.java:2024)

at java.awt.Window.dispatchEventImpl(Window.java:1774)

at java.awt.Component.dispatchEvent(Component.java:3803)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at ex12.LineDrawingFrame.paint(LineDrawingFrame.java:53)

at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)

at sun.awt.RepaintArea.paint(RepaintArea.java:224)

at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:630)

at java.awt.Component.dispatchEventImpl(Component.java:4031)

at java.awt.Container.dispatchEventImpl(Container.java:2024)

at java.awt.Window.dispatchEventImpl(Window.java:1774)

at java.awt.Component.dispatchEvent(Component.java:3803)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

java.lang.ThreadDeath

at java.lang.Thread.stop(Thread.java:698)

at java.lang.ThreadGroup.stopOrSuspend(ThreadGroup.java:671)

at java.lang.ThreadGroup.stop(ThreadGroup.java:584)

at org.netbeans.core.execution.DefaultSysProcess.stop(DefaultSysProcess.java:54)

at org.netbeans.core.execution.ProcessNodeItem$1.stop(ProcessNodeItem.java:41)

at org.netbeans.core.execution.ProcessNodeItem$TerminateProcessAction.performAction(ProcessNodeItem.java:69)

at org.openide.util.actions.NodeAction$3.run(NodeAction.java:531)

at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:47)

at org.openide.util.actions.NodeAction$DelegateAction.actionPerformed(NodeAction.java:527)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)

at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)

at javax.swing.AbstractButton.doClick(AbstractButton.java:302)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)

at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)

at java.awt.Component.processMouseEvent(Component.java:5488)

at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)

at java.awt.Component.processEvent(Component.java:5253)

at java.awt.Container.processEvent(Container.java:1966)

at java.awt.Component.dispatchEventImpl(Component.java:3955)

at java.awt.Container.dispatchEventImpl(Container.java:2024)

at java.awt.Component.dispatchEvent(Component.java:3803)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)

at java.awt.Container.dispatchEventImpl(Container.java:2010)

at java.awt.Window.dispatchEventImpl(Window.java:1774)

at java.awt.Component.dispatchEvent(Component.java:3803)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

The point of my code is to read integers from a data file, and use them to draw a picture in a window. The picture is being drawn but i cant understand where this error is coming from.

Any other code can be posted.

Cheers

[5291 byte] By [chrissmith51a] at [2007-11-26 15:21:26]
# 1
As a beginning check what is null on lines 51 and 53 of LineDrawingFrame and fix your code so that the exception is avoided.Mike
bellyrippera at 2007-7-8 21:36:16 > top of Java-index,Java Essentials,New To Java...