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 execute a function in the applet

 
Anu Kalra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a function, in which i copy a file from one drive to another drive. I have to copy 5 files. Now, the problem is that as soon as i run the applet, the files get copied, but the moment i minimise/maximise/change the size of the applet window, the function for copying the files again gets executed.
How can i avoid that.

Sample code is given below.

public class HelloApplet extends Applet
{
String s = null;

public void paint ( Graphics g )
{
g.setColor(Color.blue);
ShowMessage(g, s);

}
void ShowMessage(Graphics g, String s){
g.drawString(copy("http://.......","e:\\DataXML.xml"),0, size().height - 15);
g.drawString(copy("http://.......","e:\\toadfree.zip"),0, size().height - 35);
}
public String copy(String source_name, String dest_name)
{
.......
.......
.......
}



}
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The paint method may get executed whenever the applet gets started/resized/repainted; the user has little or no control over that. You should not use it to trigger the file copy. Or set a boolean when the copy has been done, and check that before copying.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic