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

The following examples show how to use com.alee.utils.ImageUtils#loadImageIcon() . 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
Source File: ImageIconSource.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public ImageIcon loadIcon ( @NotNull final Resource resource )
{
    return ImageUtils.loadImageIcon ( resource );
}
 
Example 2
Source File: AbstractMenuGenerator.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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
Source File: WebDecoratedImage.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
public WebDecoratedImage ( @NotNull final Resource resource )
{
    this ( ImageUtils.loadImageIcon ( resource ) );
}