• 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 ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

class.getResource() in applet  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm converting an application to an applet. Basically the application is just JFrame which I try to open from JApplet. The problem is, that in one of the classes:
com.mydomain.project.console.ConfigurationComponent
I have a line:
private static final ImageIcon mailIcon = new ImageIcon(ConfigurationComponent.class.getResource("resources/mail_active.gif"));
This should take the image from folder:
com/mydomain/project/resources
The image is there, when working as an application everyting is fine, but as an applet it throws a NullPointerException, probably because no image is found. How should I do this?
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maciej,
You could place the image file in the same directory on the server that your applet is in. Then to access it you just use:
getImage( getDocumentBase(), "image.gif" );
from the Applet class.
Regards,
Manfred.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!