/** * Gets an Icon by its file name. e.g. add.png would return the icon depicted in the add.png file on the * class path. * @param name The name of the icon file in the class path. May be {@code null}. * @return The Icon for the specified file name, or {@code null} if the file does not exist in the class path, or * {@code null} if the specified file name is {@code null}. */ public static Icon getIcon(String name) { if(name == null) { return null; } try { URL url = getIconURLFromIconFileName(name); if(url == null) { return null; } return new ImageIcon(url); } catch (Exception e) { return null; } }
/** * Gets an Icon by its file name. e.g. add.png would return the icon depicted in the add.png file on the * class path. * @param name The name of the icon file in the class path. May be {@code null}. * @return The Icon for the specified file name, or {@code null} if the file does not exist in the class path, or * {@code null} if the specified file name is {@code null}. */ public static Icon getIcon(String name) { if(name == null) { return null; } try { URL url = getIconURLFromIconFileName(name); if(url == null) { return null; } return new ImageIcon(url); } catch (Exception e) { return null; } }