Here you can find the source of setIcon(javax.swing.JFrame jFrame, String icon)
public static void setIcon(javax.swing.JFrame jFrame, String icon)
//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(); } } }