package ui.view; import java.awt.Image; import java.awt.Toolkit; import java.io.File; import javax.swing.ImageIcon; public class Util { static Image loadImage(Object origin, String url, int w, int h, int scale){//note: this may have to be a different class. return loadImage(origin,url) .getScaledInstance(w, h, scale); } static Image loadImage(Object origin, String url){//note: this may have to be a different class. System.out.println(url); try{ return new ImageIcon(origin.getClass().getResource(url)).getImage(); }catch(Exception e){ return new ImageIcon(Toolkit.getDefaultToolkit().createImage("res"+url)).getImage(); } } //TODO: This is a temporary solution. Fix. static File loadFile(Object origin, String url){//note: this may have to be a different class. try{ return new File(origin.getClass().getResource(url).getFile()); }catch(Exception e){ return new File("res"+url); } } }