}
public static Image loadImage ( String strFileName ) {
Image image = null;
URL url;
Toolkit toolkit;
Class classObject;
Object objImageProducer;
ImageProducer imageProducer;
BufferedInputStream streamImage;
byte arrImageBytes [];
toolkit = Toolkit.getDefaultToolkit ();
try {
classObject = Class.forName ( "jamp.MainWindow" );
url = classObject.getResource ( strFileName );
if ( url != null ) {
objImageProducer = url.getContent ();
if ( objImageProducer instanceof ImageProducer ) {
imageProducer = (ImageProducer) objImageProducer;
image = toolkit.createImage ( imageProducer );
}
else if ( objImageProducer instanceof BufferedInputStream ) {
streamImage = (BufferedInputStream) objImageProducer;
arrImageBytes = new byte [streamImage.available()];
streamImage.read ( arrImageBytes );
image = toolkit.createImage ( arrImageBytes );
}
}
}
catch ( Exception exception ) {
exception.printStackTrace ();