Error at drawing on the Canvas

L

lrantisi

I have the following code:

Graphics canvasGraphics
canvasGraphics.drawLine(x, y, 200, 200);

which works fine on a machine. But on another machine, I receive the
following error messages.

===============
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at pan$1.mouseClicked(pan.java:82)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(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)
+++++======================

Why do I get this
 
A

Andrew Thompson

I have the following code:

Graphics canvasGraphics
canvasGraphics.drawLine(x, y, 200, 200);

That code does not compile.
which works fine on a machine.

No it wouldn't. It would not even compile.
Please stop wasting your time, and our bandwdidth,
posting snippets of code that do not express the
problem.

I recommend you prepare an SSCCE that shows the
same behaviour, and post that instead.
<http://www.physci.org/codes/sscce.html>

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top