Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Wiki
Search Coderanch
Advance search
Google search
Register / Login
Bookmark Topic
Watch 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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Wiki
Code Barn Load A Gif Msg
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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() , "horsenav.gif" ); theMoose = getImage( getCodeBase() , "moosenav.gif" ); MediaTracker mt = new MediaTracker( this ); mt.addImage( theHorse , 0 ); mt.addImage( theMoose , 1 ); try { mt.waitForAll(); // block here until images are downloaded } catch ( InterruptedException e ) { } showWaitMsg = false ; // it is safe for paint to draw the image now repaint(); } // 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 } else { g.drawImage( theHorse , 25 , 25 , this ); g.drawImage( theMoose , 25 , 130 , this ); } } // close paint } // close applet
CodeBarnApplets
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Image is not getting loaded in applet
JPEG file not getting loaded in the aspplet
negated boolean
drawImage not getting the image drawn before printing!
Creating Java applet
More...