Here you can find the source of setWindowIcon(JFrame jd)
public static void setWindowIcon(JFrame jd)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; import java.awt.image.*; public class Main { private static ImageIcon gDefaultFrameIcon; public static void setWindowIcon(JDialog jd) { ImageIcon frameIcon = getDefaultFrameIcon(); if (frameIcon != null) jd.setIconImage(frameIcon.getImage()); }//from w ww . ja v a2 s . com public static void setWindowIcon(JFrame jd) { ImageIcon frameIcon = getDefaultFrameIcon(); if (frameIcon != null) jd.setIconImage(frameIcon.getImage()); } public static ImageIcon getDefaultFrameIcon() { return gDefaultFrameIcon; } /** * draw the component as an image * * @param component * @return */ public static BufferedImage getImage(JComponent component) { BufferedImage ret = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics g = ret.getGraphics(); component.paint(g); g.dispose(); return ret; } }