File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes What is the problem with this programm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the problem with this programm" Watch "What is the problem with this programm" New topic
Author

What is the problem with this programm

omer omran
Greenhorn

Joined: Mar 24, 2004
Posts: 3
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

Joined: Jul 08, 2003
Posts: 24166
    
  30

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().


[Jess in Action][AskingGoodQuestions]
omer omran
Greenhorn

Joined: Mar 24, 2004
Posts: 3
Thanks :
But the while loop int the init() methode to make multible moving rectangle at random, not single rectangle .
how can I make that .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the problem with this programm
 
Similar Threads
New to Java. Need some proformance suggestions
Racing game does not work(HELP!!!!)
Applet compiles but displays nothing
the display of my applet in html got problem~
why can't I access my variable?