19,19c19,19 < import java.util.List; --- > import java.util.Set; 39a40,40 > /* Holds URLs as keys, and Images as values */ 40a42,42 > /* Holds URLs */ 41,41c43,43 < private List fRegisteredImages; --- > private Set fRegisteredImages; 45,45d46 < private static boolean fgDebug = false; 53,53c54,54 < fRegisteredImages = CollectionsFactory.current().createList(10); --- > fRegisteredImages = CollectionsFactory.current().createSet(); 66a68,69 > * If component is null, the component supplied in the > * constructor will be used. 72a76,78 > if (component == null) { > component = fComponent; > } 73,73c80,80 < MediaTracker tracker = new MediaTracker(component); --- > MediaTracker tracker = new MediaTracker(component); 77a84,86 > URL url = (URL)iter.next(); > if (basicGetImageURL(url) == null) { > tracker.addImage(loadImageURL(url), ID); 78,80d83 < String fileName = (String)iter.next(); < if (basicGetImage(fileName) == null) { < tracker.addImage(loadImage(fileName), ID); 95,95c101,101 < * Registers an image that is then loaded together with --- > * Registers a URL that is then loaded together with 98a105,106 > public void registerImageURL(URL url) { > fRegisteredImages.add(url); 99,99c113,113 < public void registerImage(String fileName) { --- > public void registerImage(String fileName) { 100,100c114,114 < fRegisteredImages.add(fileName); --- > registerImageURL(getResourceURL(fileName)); 103a110,111 > * Registers the URL for the image resource > * @see #registerImageURL 104,104d109 < * Registers and loads an image. 106,109d112 < public Image registerAndLoadImage(Component component, String fileName) { < registerImage(fileName); < loadRegisteredImages(component); < return getImage(fileName); 113,113c118,118 < * Loads an image with the given name. --- > * Loads an image URL with the given name. 114a120,121 > public Image loadImageURL(URL url) { > if (fMap.containsKey(url)) { 115,116d119 < public Image loadImage(String filename) { < if (fMap.containsKey(filename)) { 117,117c122,122 < return (Image) fMap.get(filename); --- > return (Image) fMap.get(url); 119,119c124,124 < Image image = loadImageResource(filename); --- > Image image = loadImageResourceURL(url); 121,121c126,126 < fMap.put(filename, image); --- > fMap.put(url, image); 125a131,135 > /** > * Loads an image with the given name. > */ > public Image loadImage(String fileName) { > return loadImageURL(getResourceURL(fileName)); 125a148,172 > public Image loadImageResource(String fileName) { > return loadImageResourceURL(getResourceURL(fileName)); > } > > /** > * Registers and loads an image. > * If component is null, the component supplied in the > * constructor will be used. > */ > public Image registerAndLoadImageURL(Component component, URL url) { > registerImageURL(url); > loadRegisteredImages(component); > return getImageURL(url); > } > /** > * Registers and loads an image. > * If component is null, the component supplied in the > * constructor will be used. > */ > public Image registerAndLoadImage(Component component, String fileName) { > return registerAndLoadImageURL(component, getResourceURL(fileName)); > } > > public Image loadImageURL(URL url, boolean waitForLoad) { > Image image = loadImageURL(url); 126,127d147 < public Image loadImage(String filename, boolean waitForLoad) { < Image image = loadImage(filename); 128,128c173,173 < if (image!=null && waitForLoad) { --- > if (image!=null && waitForLoad) { 129,129c174,174 < ImageIcon icon = new ImageIcon(image); --- > ImageIcon icon = new ImageIcon(image); 130,130c175,175 < image = icon.getImage(); //this forces the wait to happen --- > image = icon.getImage(); //this forces the wait to happen 131,131c176,176 < } --- > } 132a178,183 > } > > public Image loadImage(String fileName, boolean waitForLoad) { > return loadImageURL(getResourceURL(fileName), waitForLoad); > } > 132,132c177,177 < return image; --- > return image; 134a138,138 > public Image loadImageResourceURL(URL url) { 135,135d137 < public Image loadImageResource(String resourcename) { 138,141d140 < URL url = getClass().getResource(resourcename); < if (fgDebug) { < System.out.println(resourcename); < } 149a185,186 > * Gets the image with the given URL. If the image can't be > * found it tries it again after registering the image and 150,151d184 < * Gets the image with the given name. If the image < * can't be found it tries it again after loading 152,152c187,187 < * all the registered images. --- > * loading all the registered images. 153a189,190 > public Image getImageURL(URL url) { > Image image = basicGetImageURL(url); 154,155d188 < public Image getImage(String filename) { < Image image = basicGetImage(filename); 158a194,194 > registerImageURL(url); 161a198,206 > return basicGetImageURL(url); > } > /** > * Gets the image with the given fileName. If the image can't > * be found it tries it again after registering the image and > * loading all the registered images. > */ > public Image getImage(String fileName) { > return getImageURL(getResourceURL(fileName)); 162,162d197 < return basicGetImage(filename); 164a209,214 > private URL getResourceURL(String resourceName) { > return getClass().getResource(resourceName); > } > > private Image basicGetImageURL(URL url) { > if (fMap.containsKey(url)) { 165,166d208 < private Image basicGetImage(String filename) { < if (fMap.containsKey(filename)) { 167,167c215,215 < return (Image) fMap.get(filename); --- > return (Image) fMap.get(url); 170a219,219 >