Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

images not loaded.........

 
atif dar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am accessing the applet resieding on the linux server...i am accessing mysql database as well...what is happening is that every things loads properly except for the image.....i have tried to change the extensions from Gif to png and jpg but nothing seems to work...how can i load these images....because on my local computer running windows every thing works fine...
 
Joe Ess
Bartender
Posts: 9370
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using Applet.loadImage() to get the gif? According to the documentation for java.applet.Applet:
This method always returns immediately, whether or not the image exists. When this applet attempts to draw the image on the screen, the data will be loaded

So the image data is probably not being loaded before you try to display it. You need to use a java.awt.MediaTracker to insure that the image is completely loaded.
 
atif dar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am simply using this

URL url=getCodeBase();
im=getImage(url,"1.gif");

and than in paint

g.drawImage(im,0,0,this);

and on windows platform it works really well but when i try to load it from linux it doesn't work...anyway i will try out media tracker thanks for advice
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!