The moose likes Applets and the fly likes JApplet resources Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Applets
Reply Bookmark "JApplet resources" Watch "JApplet resources" New topic
Author

JApplet resources

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 179

Hi

I made a simple applet in NetBeans which can display 8 JPG images. It uses a CardLayout. I can see the JPG images when I test it in NetBeans, but when I uploaded everything and tested it with FireFox, I see a light gray panel where the first image should be. I see the JLabel in the south region and when I click on each panel the label cycles through each file name but there is never an image. My applet file resides in the default package and I have the JAR and CLASS files in the same place on my web space along with the JPG files. The JApplet loads on the webpage without any errors.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 681
If you are loading and running the applet using a server, then the applet must use URLs to get to the image files on the server. How are you loading the images in the applet? You would use getCodeBase() to get the URL of where the applet loaded from and append to that the path to the image file.
If the images are in the jar file, use getResourceAsStream()
[ August 07, 2008: Message edited by: Norm Radder ]
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 179

ok Norm, I'll give it a try.
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 179

stupid absent mindedness. it's been so long since I did an applet.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JApplet resources
 
Similar Threads
Problem laying out panels in an Applet
Problem in Image Loading in Swing Applet
Random images Project.
Need help understanding random loops. code inside
Standalone app worked... as Applet does not.