Tim,
by saying "blank" you probably mean a grey background? It seems to me that
your program loops or sleeps forever - this would lead to a hanging event
dispatcher thread and no further paintings.
Could you post your source-code into the list? I'm shure we can solve the
problem then.
Regards
Sven
----- Original Message -----
From: Tim Huntington <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 21, 2001 4:28 PM
Subject: [JAVA2D] Animation from Simulation Data
> Hello to everyone on the list. I'm a new Java programmer and have a
> question which despite some effort I haven't been able get answered.
>
> As a vehicle to learning Java I've been writing a single program. This is
a
> crowd simulator. The idea is to create a large number of objects
> representing groups of people, have them interact in a 2-d array
> (representing a large open space like a park), and display their spatial
> locations in a scrollable JLabel. In other words this is animation of a
> large number of "sprites" that are moving pretty slowly (like the game
Life
> running at a slow speed).
>
> My main method invokes a constructor which creates a GUI object, which
> itself creates a "scrollableMap" object. This scrollableMap contains the
> update() method I use to create a bufferedImage. The main method then
> creates a thread, which creates Unit objects (the groups of people) and
puts
> them in a static array. Finally, the thread enters a while loop which
first
> goes through the array of units and moves each one, and then sleeps for
50ms
> before doing it again.
>
> Here's the problem. My update() method in the scrollableMap creates a
> bufferedImage and I can use graphics primitives (e.g. fillRect(...)) to
draw
> to the buffer and then drawthis image to the scrollableMap. So my
buffered
> image works fine. What Ican't do is get position data for my units into
the
> update() method. When I try to do this, e.g. in the update method trying
to
> invoke methods in the
> game thread, my GUI comes out all blank.
>
> All the animation examples I've seen involve some sort of computation to
> determine where to draw shapes, and these computations are always very
> self-contained so they can sit in an update or paint method. I've looked
at
> lots of animation demo programs but haven't found any that access data or
> methods "beyond themselves." For my simulation the final x,y coordinates
> for each sprite will be the product of a large "sim-side" to the program.
I
> can't do the whole simulation in an update() or paint(). When I try to
get
> data from outside these methods my GUI goes blank. I've been careful to
put
> an if-statement in the update() so it doesn't try to access unit data
until
> the units are created, but it makes no difference.
>
> If there is some fundamental problem with accessing objects and methods
> outside an update() from within the update() I would appreciate any advice
> on how to get around this. Thank you very much for your time.
>
> Tim Huntington
> Boston, MA
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".