Load an Icon from a jar (again)Tag(s): AWT
public static ImageIcon getImageIcon(String name) {
return new ImageIcon(ClassLoader.getSystemResource(name));
}
ImageIcon img = getImageIcon("resources/images/icone.gif");
public static Icon getIconForType(int iconType) {
switch (iconType) {
case 0:
return UIManager.getIcon("OptionPane.errorIcon");
case 1:
return UIManager.getIcon("OptionPane.informationIcon");
case 2:
return UIManager.getIcon("OptionPane.warningIcon");
case 3:
return UIManager.getIcon("OptionPane.questionIcon");
}
return null;
}
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com