• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the problem with this programm

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
He's giving us the slip! Quick! Grab this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic