throw new IllegalArgumentException();
}
if (icons != null)
{
final Image cachedIcon = icons[iconKind - 1];
if (cachedIcon != null)
{
return cachedIcon;
}
}
final String iconName;
switch (iconKind)
{
case BeanInfo.ICON_COLOR_16x16:
iconName = getBundle(locale).getString(getKeyPrefix() + getName() + ".icon-color-16");
break;
case BeanInfo.ICON_COLOR_32x32:
iconName = getBundle(locale).getString(getKeyPrefix() + getName() + ".icon-color-32");
break;
case BeanInfo.ICON_MONO_16x16:
iconName = getBundle(locale).getString(getKeyPrefix() + getName() + ".icon-mono-16");
break;
case BeanInfo.ICON_MONO_32x32:
iconName = getBundle(locale).getString(getKeyPrefix() + getName() + ".icon-mono-32");
break;
default:
throw new IllegalArgumentException();
}
URL url = ObjectUtilities.getResource(iconName, DefaultElementMetaData.class);
if (url == null)
{
final String fallbackIcon = getBundle(locale).getString(getKeyPrefix() + getName() + ".icon");
url = ObjectUtilities.getResource(fallbackIcon, DefaultElementMetaData.class);
if (url == null)
{
return null;
}
}
if (icons == null)
{
icons = new Image[4];
}
final Image retval = Toolkit.getDefaultToolkit().createImage(url);
icons[iconKind - 1] = retval;
return retval;
}