List of utility methods to do ImageIcon Create
ImageIcon | createImageIcon(String imgFile) create image icon URL imgUrl = ClassLoader.getSystemClassLoader().getResource(imgFile); if (imgUrl == null) { return null; return new ImageIcon(imgUrl); |
ImageIcon | createImageIcon(String path) Create an ImageIcon from the image at the specified path URL u = Thread.currentThread().getContextClassLoader().getResource(path); if (u == null) { return null; return new ImageIcon(u); |
ImageIcon | createImageIcon(String path) Create an ImageIcon from the image at the specified path URL u = Thread.currentThread().getContextClassLoader().getResource(path); if (u == null) return null; return new ImageIcon(u); |
ImageIcon | createImageIcon(String path) Creates an icon from an image path. URL imgURL = null; try { imgURL = new URL("file:" + path); } catch (MalformedURLException e) { e.printStackTrace(); if (imgURL != null) { return new ImageIcon(imgURL); ... |
ImageIcon | createImageIcon(String path) create Image Icon java.net.URL imgURL = ClassLoader.getSystemResource(path); if (imgURL != null) return new ImageIcon(imgURL); else throw new FileNotFoundException(path); |
ImageIcon | createImageIcon(String path, Class resourceClass) create Image Icon java.net.URL imgURL = resourceClass.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL); } else { System.err.println("Couldn't find file: " + path); return null; |
ImageIcon | createImageIcon(String path, Class> c) Create an Image icon from the provided path. URL imgURL = c.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL); } else { return null; |
ImageIcon | createImageIcon(String path, int width, int height) create Image Icon URL imgURL = ClassLoader.getSystemResource("img/" + path); return new ImageIcon( new ImageIcon(imgURL).getImage().getScaledInstance(width, height, Image.SCALE_DEFAULT)); |
ImageIcon | createImageIcon(String path, String description) Returns an ImageIcon, or null if the path was invalid. return new ImageIcon(path, description); |
ImageIcon | createImageIcon(String path, String description) Returns an ImageIcon, or null if the path was invalid. java.net.URL imgURL = Thread.currentThread().getContextClassLoader().getResource(path); if (imgURL != null) { return new ImageIcon(imgURL, description); } else { System.err.println("Couldn't find file: " + path); return null; |