• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pause applet execution until Image file is completely downloaded?

 
Matt Wil
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My applet downloads an image file(about 1 meg) and then adds text to it. Problem is, when I try printing it, it looks as if only part of the image downloaded. You can see about 25% of the image but there are odd color bands mixed in with it. The rest of the image is just gray. Im assuming the applet moving forward before it downloads the entire file. Any way to pause execution until the entire file is downloaded? A code snippet is below.
Thanks!

//load image
try{
URL url = new URL("http://www.example.com/ImageData/" + selectedAd + "Full.dat");
openFile = url.openStream();
}catch (FileNotFoundException e){
e.printStackTrace(System.err);
}

try{
AdMakerApp.adObject.setAd(ImageIO.read(openFile));
}catch(IOException e){
e.printStackTrace(System.err);
}

//close input file
try{
openFile.close();
openFile=null;
}catch(IOException e){
e.printStackTrace(System.err);
}
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.awt.MediaTracker
does exactly that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic