How to change Frame Icon in JAVA?
This tutorial teaches the technique of changing in the upper-left corner of a window? The default icon used by JAVA is a coffee cup which is the offical logo of JAVA. I really wanted to get rid of this cup and replace it with my own logo. I did quite a bit of research on this topic and found some cool tips. But couldn’t find any tutorials on NetBeans IDE. The problem is that, the code wasn’t NetBeans friendly. So I’ve modified it to suit every need.
The code for those who don’t use NetBeans IDE:
Note: 1)You have to import the Toolkit Package
import java.awt.Toolkit;
2) Image icon = Toolkit.getDefaultToolkit().getImage(”icon_confused.gif”);
frame.setIconImage(icon);
For NetBeans IDE users:
1)You have to import the Toolkit Package
2)In the Netbeans properties window for your Frame, try iconImage.
->Select Custom Code
->Add the following line:
setIconImage(Toolkit.getDefaultToolkit().getImage(SampleFrame.class.getResource(”/image/logo.png”)));
/**Here SampleFrame is the JFrame class name.*/
/**The logo can be placed inside a folder named ‘image’. Relative path is used to access the logo*/
Now you have your own customised logo on the Frame window. Cheers! ![]()
I have used it on my B.E final year project.

This post has one comment
November 17th, 2009
Its been long no updates Andrew !!!