How to program a Java applet that needs lots of images(some really big), and be successful with no erros?


Question: It's very weird. i load 80 images and it works.
but then i load 60 smaller images and i get a message "Applet not initialized" when i try to view the applet.

This applet i'm making is a game in the form
applet{

run()

star()
stop()
paint()
and other methods

}
and i load the images in the form
x = getImage( getCodeBase() + "hello.jpg" );

and i also use Mediatracker to track images. I give each loaded image a tracker id. then at the end of init() , i say t.waitForAll.

It's weird, how the program loads 1000 X 600, but can't load a bunch of images that are 40 X 47, or 100 X 100 , or something like that. Also, for loading 80 big 1000 X 600, it was just a test to see if it was a memory problem why i couldn't load the other images. But loading 80 big images and no problems,,, ,that made me think it's not memory related,, but who knows what else.

By the way this is not used in the web. it's an applet i use in my computer

Answer:
Have you tried instrumenting your code? In other words, have you tried putting in println() statements and also bringing up the Java Plugin Console to see if/what exceptions are being generated? Apparently, something "bad" is happening in your init() method.

Go to Control Panel -> Java (Java Control Panel). Select the Advanced tab, expand Java Console, and select Show Console. This way, you will get more feedback on what is happening at runtime (exception stacktraces, etc.).

BTW, I have seen this problem before, and it is typically due to a "bad" file name, e.g. a file name typo. I often will rename the files to something like t1.jpg, t2.jpg, etc., so that I can load them in a loop that just incremements the "base" name, thus avoiding typos:
for (int i = 1;i < 20; i++){
String file = "t" + i + ".jpg";
x = getImage(getCodebase() + file);
appletContext.showStatus(
"Loading image " + file);
}
More Questions & Answers...
  • Proxy sniffer?
  • I need a smart computer nerd that knows php well.?
  • HTML, I have designed some simple web pages, had them validated on W3C validator and they pass ok.?
  • Trying to load the drivers for a powerdata S900 pc camera on my computer with windows XP.?
  • I can't connect to the internet with my laptop what should I do?
  • What is capacity planning and load testing?
  • Can you help me with these questions?
  • Pull-down menu on web page doesn't work properly?
  • The questions and answers post by the user, for information only, AnswersRoom.com does not guarantee the right
    Copyright © 2007 AnswersRoom.com -   Terms of Use -   Contact us

    Hot Topic