Java JFrame Icon setIcon(javax.swing.JFrame jFrame, String icon)

Here you can find the source of setIcon(javax.swing.JFrame jFrame, String icon)

Description

Change title bar icon.

License

Open Source License

Declaration

public static void setIcon(javax.swing.JFrame jFrame, String icon) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /** //w  w  w . jav a  2s  .c  o m
     * Change title bar icon.
     */
    public static void setIcon(javax.swing.JFrame jFrame, String 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();
        }
    }
}

Related

  1. getResourceIcon(JFrame fr, String name, Class callingClass)
  2. loadIMageIconToPanel(JFrame frame, JPanel panel, ImageIcon icon)
  3. SET_FRAME_ICON(JFrame f, String iconPath)
  4. setApplicationIcon(JFrame frame)
  5. setDefaultIcon(final JFrame window, final String imagepath)
  6. setIconImage(JFrame frame, Class clazz, String path)
  7. setIconImageFromResource(JFrame frame, String resource)
  8. setIconOnFrame(JFrame frame)
  9. setWindowIcon(JFrame jd)