October 10, 2016
					    							
												Java JFrame change Icon
I have learn about GUI programming using java this week. I have created a simple window (using JFrame) and get the default icon in titlebar is a default java icon. But, I dont like this default icon image and want to change with another image.
This is a complete code how to change JFrame icon image
package jframechangeicon;
import java.awt.Dimension;
import java.awt.Toolkit;
/**
 *
 * @author toto
 */
public class JframeChangeIcon extends javax.swing.JFrame
{
    public JframeChangeIcon()
    {
        setTitle("MainWindow");
        //change java image
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/jframeChangeicon/image/appicon.png")));
    }
    
    public static void main(String[] args)
    {
        JframeChangeIcon  frame = new JframeChangeIcon();
        frame.setSize(new Dimension(500, 300));
        frame.setVisible(true);
    }    
}
This is the Program Window result after JFrame change the icon
 Download the complete source code how JFrame change the icon below.
Download the complete source code how JFrame change the icon below.
Source code : jframeChangeIcon.zip
