• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the problem with this programm

 
omer omran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why the applet does not work in the html page .
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ April 27, 2004: Message edited by: Dirk Schreckmann ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yikes!
- Your init() method will never return; it will loop forever creating threads (at least until the VM runs out of memory.)
- init() runs on the Swing event thread, so the screen will never be repainted (since you're blocking the painting thread.) This means that the counter will never be incremented, which means that none of these threads will ever terminate.
- Every thread creates its own Car object, none of which will actually be displayed on the screen (only the original one will be) so all those repaint() calls won't do anything anyway!
To get you on the right track: rename your "init()" method to "start()", and get rid of that "while" loop; then in "run", get rid of the variable "c" altogether. Don't create any Car object, and refer to the member variable "i" implicitly.
Note that since you haven't overridden stop() to do anything, calling it will have no effect. What you want to do is break out of that while loop, not call stop().
 
omer omran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks :
But the while loop int the init() methode to make multible moving rectangle at random, not single rectangle .
how can I make that .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic