Java Code Examples for com.alee.utils.ImageUtils#loadImageIcon()

The following examples show how to use com.alee.utils.ImageUtils#loadImageIcon() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@NotNull
@Override
public ImageIcon loadIcon ( @NotNull final Resource resource )
{
    return ImageUtils.loadImageIcon ( resource );
}
 
Example 2
/**
 * Returns {@link Icon} for the specified source {@link Object}.
 *
 * @param icon either {@link Icon}, {@link Image}, {@link Resource}, path, {@link File} or {@link URL}
 * @return {@link Icon} for the specified source {@link Object}
 */
@Nullable
protected Icon getIcon ( @Nullable final Object icon )
{
    final Icon result;
    if ( icon != null )
    {
        if ( icon instanceof Icon )
        {
            result = ( Icon ) icon;
        }
        else if ( icon instanceof Image )
        {
            result = new ImageIcon ( ( Image ) icon );
        }
        else
        {
            final Resource resource;
            if ( icon instanceof Resource )
            {
                resource = ( Resource ) icon;
            }
            else if ( icon instanceof String )
            {
                try
                {
                    if ( getNearClass () != null )
                    {
                        resource = new ClassResource ( getNearClass (), getPath () + icon + getExtension () );
                    }
                    else
                    {
                        resource = new FileResource ( new File ( getPath (), icon + getExtension () ) );
                    }
                }
                catch ( final Exception e )
                {
                    throw new UtilityException ( "Unable to find menu icon for path: " + getPath () + icon + getExtension (), e );
                }
            }
            else if ( icon instanceof File )
            {
                resource = new FileResource ( ( File ) icon );
            }
            else if ( icon instanceof URL )
            {
                resource = new UrlResource ( ( URL ) icon );
            }
            else
            {
                throw new UtilityException ( "Unknown icon object type provided: " + icon );
            }
            result = ImageUtils.loadImageIcon ( resource );
        }
    }
    else
    {
        result = null;
    }
    return result;
}
 
Example 3
public WebDecoratedImage ( @NotNull final Resource resource )
{
    this ( ImageUtils.loadImageIcon ( resource ) );
}