Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multithreaded Pacman: only last animated panel added to JFrame is displaye

843806Apr 16 2009 — edited Apr 16 2009
Hello,

I am making a multithreaded pacman game. Pacman and each of the ghosts run in a separate thread.

However, only the last item (ie. pacman or one of the ghosts) added to the JFrame is displaying in the maze. (pacman and each of the ghosts are subclasses of JPanel). For example, if I do:

add(pacman);
add(orangeGhost);
add(redGhost);

only the red ghost animation will appear on the maze(which is also a subclass of JPanel).

I have tried adding the ghosts to pacman and then adding pacman i.e. pacman.add(redGhost); add(pacman); but this still doesn't work - only pacman is showing in the maze.

Each thread runs fine on its own, but only the last one added is displaying.

Any help is much appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2009
Added on Apr 16 2009
3 comments
267 views