/** * Attempts to load an image from classpath. If this fails, an empty image icon is returned. * * @param resourceName the name of the image. The name should be a global resource name. * @param scale true, if the image should be scaled, false otherwise * @param large true, if the image should be scaled to 24x24, or false for 16x16 * @return the image icon. */ private ImageIcon createIcon( final String resourceName, final boolean scale, final boolean large ) { final URL in = sourceClassLoader.getResource( resourceName ); if ( in == null ) { logger.warn( "Unable to find file in the class path: " + resourceName ); return new ImageIcon( createTransparentImage( 1, 1 ) ); } final Image img = Toolkit.getDefaultToolkit().createImage( in ); if ( img == null ) { logger.warn( "Unable to instantiate the image: " + resourceName ); return new ImageIcon( createTransparentImage( 1, 1 ) ); } if ( scale ) { if ( large ) { return new ImageIcon( img.getScaledInstance( 24, 24, Image.SCALE_SMOOTH ) ); } return new ImageIcon( img.getScaledInstance( 16, 16, Image.SCALE_SMOOTH ) ); } return new ImageIcon( img ); }
return new ImageIcon(createTransparentImage(1, 1)); return new ImageIcon(createTransparentImage(1, 1));