• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

dynamic Drawing -->Vector ?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator

[ July 29, 2004: Message edited by: Craig Wood ]
 
What's wrong? Where are you going? Stop! Read this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!