posted 18 years ago
I have a basic question about painting.
When I want to add dynamically lines,
is it possible to append everytime one line to my Graphic Context?
I tried so, but everytime it repaints(), all previouse lines got lost.
So I stored them all in a Vector, and each time the Panel repaints,
it gets the whole data from the Vector to draw.
The Problem is now,that I sometimes get a NullPointer Exception, but I don't know exactly why.
So, I think it's not a good solution for my Problem.
I have to cast each Element of my Vector to a Basic type, that I've defined in as an extra Interface. This Basic-Type just has the method paint().
Otherwise it was'nt possible to draw the elements of my Vector.
The elements were just Line-Objects (I also wrote a class Line, that implements Basic)
I did it like this:
and got java.lang.NullPointerException
This appears only sometimes, I don'tknow exactly why...It seems there is a rerference to an object that does not exists?
The Code how I build this Vector:
(The function gets a Vector filled with Point-Objects)
and for completion, here is the "Line" Class I've defined:
[ July 29, 2004: Message edited by: Raschin Ghanad ]
[ July 29, 2004: Message edited by: Raschin Ghanad ]