Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python
C++

JAVA


PHP
SQL
Alice

ImageTest


Description
ImageTes is a simple applet, written by Jason Stark, that shows one method of placing images (jpg or gif, for example) into applets.

There seems to be many ways of putting an image into an applet, but depending on whether or not the files are in a jarfile seems to change whether or not the pictures display. I am still trying to figure out what the problems are.

Here is a brief description given by the author of the code:

The applet loads the images from a jar file. The top image is an actual Image painted on a JPanel, and the bottom image is just an ImageIcon added to a JLabel.

Basically, to extract an image (or anything, for that matter) from a jar file, just use the

this.getClass().getResource("filename-of-the-image.jpg");

getResource returns a URL which points to the image in the JAR file.