Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

JPEG file not getting loaded in the aspplet  RSS feed

Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have downloaded the folowing code from javaranch site.
Able to compile the java prog, im getting msg applet started at the status bar but image is not getting loaded,I tried printing the msg in the where im calling g.drawImage () method.String is displayed on the applet but image is not coming.can any one tel what could be the reason .

thnx & regards

import java.applet.* ;
import java.awt.* ;

public class LoadAGifMsg extends Applet
private Image theHorse ;
private Image theMoose ;
private boolean showWaitMsg = true ; // will be set to false after image downloads

public void init()
// anything in here will run BEFORE the paint() method is called,
// even if you call repaint() now inside init
} // close init

public void loadGraphics()
// now load the graphics - this is like your "real" init
theHorse = getImage( getCodeBase() , "M1.JPEG" );
theMoose = getImage( getCodeBase() , "M2.JPEG" );
MediaTracker mt = new MediaTracker( this );
mt.addImage( theHorse , 0 );
mt.addImage( theMoose , 1 );

mt.waitForAll(); // block here until images are downloaded
catch ( InterruptedException e )

showWaitMsg = false ; // it is safe for paint to draw the image now
} // close loadGraphics

public void paint( Graphics g )
// test a boolean to if the "loading" message should be displayed
if ( showWaitMsg )
g.drawString( "Please wait... loading..." , 20 , 20 );
loadGraphics(); // call the method that actually loads the graphics
g.drawImage( theHorse , 25 , 25 , this );
g.drawImage( theMoose , 25 , 130 , this );
} // close paint
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This forum is devoted to Servlets.
There is an applet forum on this site where.
You're question would do better there.

Rather than re-post the question, just PM one of the moderators/sherrifs and ask them to move it for you.

Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Duplicate in the Applets forum, this copy is closed.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!