Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to stop the Execution of Applet?

 
Waqas Tariq
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
Problem:
i want to stop the execution of start() method of my Applet by clicking a hyper link on my html page(in which this applet exist). Now, execution of my applet does not stop even i close the browser. It stops execution when i close ALL instances of my browser(e.g. firefox) opened at that time.
Code of start():

i want to stop above while() loop, when user clicks a hyperlink OR a Swing Button OR a html form Button.


Best wishes,
Waqas Dar
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, you should not keep long-running code inside of the start method (it should terminate quickly). For continuously running code you should start its own thread.

Terminating a thread when a Swing button is clicked is comparatively easy. Instead of "while (true)" do something like
and add a setter that can set run to false whenever the button is clicked.

Having the applet react to events on the web page (like clicking on a link or form button) involves JavaScript and either LiveConnect or the Common DOM API. More information about both can be found here.
[ January 07, 2008: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic