diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/UI.java b/Mage.Client/src/main/java/org/mage/card/arcane/UI.java index 6dd0add5d7..a84f4415ce 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/UI.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/UI.java @@ -14,7 +14,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; import java.util.concurrent.ConcurrentHashMap; @@ -45,7 +46,7 @@ import javax.swing.text.html.ImageView; * UI utility functions. */ public class UI { - private static ConcurrentMap imageCache = new ConcurrentHashMap(); + private static ConcurrentMap imageCache = new ConcurrentHashMap(); public static JToggleButton getToggleButton () { JToggleButton button = new JToggleButton(); @@ -69,17 +70,6 @@ public class UI { } } - public static URL getFileURL (String path) { - File file = new File(path); - if (file.exists()) { - try { - return file.toURL(); - } catch (MalformedURLException ignored) { - } - } - return UI.class.getResource(path); - } - public static ImageIcon getImageIcon (String path) { try { InputStream stream; @@ -117,9 +107,14 @@ public class UI { @Override public URL getImageURL() { URL url = super.getImageURL(); + URI uri = null; + try { + uri = url.toURI(); + } catch (URISyntaxException ex) { + } // Put an image into the cache to be read by other ImageView methods. - if (url != null && imageCache.get(url) == null) { - imageCache.put(url, Toolkit.getDefaultToolkit().createImage(url)); + if (uri != null && imageCache.get(uri) == null) { + imageCache.put(uri, Toolkit.getDefaultToolkit().createImage(url)); } return url; }