Java Utililty Methods JFrame Icon

List of utility methods to do JFrame Icon

Description

The list of methods to do JFrame Icon are organized into topic(s).

Method

voidgetResourceIcon(JFrame fr, String name, Class callingClass)
Set a icon for given frame CallingClass is used to determine where to find resource...
try {
    ImageIcon i = null;
    i = new ImageIcon(callingClass.getResource(name));
    fr.setIconImage(i.getImage());
} catch (Exception e) {
    System.out.println("Icon not loaded: " + name);
voidloadIMageIconToPanel(JFrame frame, JPanel panel, ImageIcon icon)
load I Mage Icon To Panel
JLabel label = new JLabel();
label.setIcon(icon);
panel.add(label);
frame.add(panel);
frame.setVisible(true);
voidSET_FRAME_ICON(JFrame f, String iconPath)
SEFRAMICON
f.setIconImage(new ImageIcon(f.getClass().getResource(iconPath)).getImage());
voidsetApplicationIcon(JFrame frame)
set Application Icon
try {
    frame.setIconImage(Toolkit.getDefaultToolkit()
            .getImage(new URL("http://gaggle.systemsbiology.net/images/icons/gaggle_icon_32x32.gif")));
} catch (MalformedURLException ignore) {
    ignore.printStackTrace();
voidsetDefaultIcon(final JFrame window, final String imagepath)
Sets the icon for a window.
window.setIconImage(Toolkit.getDefaultToolkit().getImage(imagepath));
voidsetIcon(javax.swing.JFrame jFrame, String icon)
Change title bar icon.
java.net.URL url = jFrame.getClass().getResource(icon);
try {
    java.awt.Image img = jFrame.createImage((java.awt.image.ImageProducer) url.getContent());
    jFrame.setIconImage(img);
} catch (Exception e) {
    e.printStackTrace();
voidsetIconImage(JFrame frame, Class clazz, String path)
set Icon Image
BufferedImage image = readIconImage(clazz, path);
if (image != null) {
    frame.setIconImage(image);
voidsetIconImageFromResource(JFrame frame, String resource)
Set the icon image for a JFrame from a resource in its class.
Image image = null;
if (frame != null && resource != null) {
    image = getImageFromClassResource(frame.getClass(), resource);
frame.setIconImage(image);
voidsetIconOnFrame(JFrame frame)
set Icon On Frame
if (logoImage == null) {
    URL logoResourceURL = frame.getClass().getResource("/resources/SkyggeLogo.png");
    ImageIcon logoImageIcon = new ImageIcon(logoResourceURL);
    logoImage = logoImageIcon.getImage();
frame.setIconImage(logoImage);
voidsetWindowIcon(JFrame jd)
set Window Icon
ImageIcon frameIcon = getDefaultFrameIcon();
if (frameIcon != null)
    jd.setIconImage(frameIcon.getImage());