• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

dynamic Drawing -->Vector ?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[ July 29, 2004: Message edited by: Craig Wood ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic