• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help showing drawing items

 
Jeff Ciaccio
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to show a rectangle "flying" across a panel, but it just sits there Any suggestions?



and here is MyPanel:

 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeff Ciaccio:
Hi all,

I am trying to show a rectangle "flying" across a panel, but it just sits there Any suggestions?




From which thread are you calling runProj()?

If you're calling it from the EDT then it won't be able to react to the repaint while you have it sleeping.

If you're not calling it from the EDT, then you may run into threading issues of another sort.

You might want to look into using a Timer.
[ November 26, 2008: Message edited by: Brian Cole ]
 
Jeff Ciaccio
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Man, you ain't kidding about the thread issues!! I spent all afternoon yesterday just to figure out it was a thread issue I was also without Internet connectivity or your post may have saved me a couple of hours.

Cheers - Jeff
 
Campbell Ritchie
Marshal
Posts: 52580
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can, find a copy of Horstmann and Cornell, Core Java 2; there is a threading chapter in vol II and it has an example quite similar to your application in.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
If you can, find a copy of Horstmann and Cornell, Core Java 2; there is a threading chapter in vol II and it has an example quite similar to your application in.


You can also find the code from the book Campbell is mentioning here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!