This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help ...urgent

 
Ash sav
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.applet.Applet;
import java.awt.*;
/*
< applet code = FlashingLight.class height = 265 width=90>
< /applet>
*/

When I try to see the applet it's working fine the way i want but I don't know how to stop the applet. If I click on close then applet hangs for seconds. Can somebody tell me how can I prevent that?

[This message has been edited by Cindy Glass (edited August 21, 2001).]
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ash,
Instead of using for loops to wait why not just use the Thread.sleep(...) method. You can place it inside a try/catch block so that you can catch the InterruptedException and exit cleanly. That might stop your major delay ...

Regards,
Manfred.
 
Ash sav
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.applet.Applet;
import java.awt.*;
/*
< applet code = FlashingLight.class height = 265 width=90>
< /applet>
*/

Hi Manfred,
According to your suggestion i replace the code with try catch block but when i click on close icon applet still hangs. Can you tell me what's wrong?
Thanks,
Ash
[This message has been edited by Cindy Glass (edited August 21, 2001).]
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ash,
Your problem might not have been the for loops after all ... When I run your code I noticed that your while loop is chugging away filling in the event queue with drawing commands. When you hit stop your quit event is placed in the queue. Unfortunatly it has to wait until all the drawing commands are completed first. I think each drawing command might be starting up a new drawing thread which is why the while loop can continue to chug even though the drawing is not being completed. I am drawing a blank right now on how to fix the problem though ...
Sorry,
Manfred.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic