Image (String path, boolean preload) { if ((path == null) || (path.length() == 0)) { return null; } Image image = null; //(Image) imagepool.get(path); //midp try { //midp image = Image.createImage(path); //midp } catch (IOException ioe) {} //java> try { image = Toolkit.getDefaultToolkit().getImage(getClass().getResource(path)); //image = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource(path)); } catch (Throwable e) { } if (image == null) { try { InputStream is = getClass().getResourceAsStream(path); //InputStream is = ClassLoader.getSystemResourceAsStream(path); if (is != null) { byte[] data = new byte[is.available()]; is.read(data, 0, data.length); image = getToolkit().createImage(data); is.close(); } } catch (Throwable e) { } } //if (image == null) { // applet code // try { // image = getImage(getCodeBase(), path); // } catch (Throwable e) {} //} if (preload && (image != null)) { MediaTracker mediatracker = new MediaTracker(this); mediatracker.addImage(image, 1); try { mediatracker.waitForID(1, 50); } catch (InterruptedException ie) { } //imagepool.put(path, image); } //<java return image; }