How to change Window Icon

Can anybody please give an example code on how to change the icon in the upper-left corner of a window?
Using setImageIcon() doesn't seem to work.
If it can be changed through a property in NetBeans IDE, then how's that supposed to do?

Umm... still not working. Probably the image path isn't correct. My project name is "Test", java file (class) name is frame.java . I placed an image file named abc.jpg . The project directory structure is as below:

Since it is isn't much, post you entire .java source file containing this code - what you have there doesn't look wrong, but I'm not sure why you made a frame constructor. Your path doesn't look correct, which is likely causing your problem - have you experimented putting the .jpg in other locations? How about within build/classes where your class is located? Isn't this where a java program is run, by using classes, right? So wouldn't it make sense to put the .jpg in the classes folder? I dunno, you tell me.

Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)

And the image must be placed in the project root directory - in this case,
Test -> abc.jpg

But the problem is, the JAR file produced by NetBeans 6 doesn't include that image file and hence showing the default coffee-cup icon instead. I added the image file in the JAR file, but nothing changed. When running from the NetBeans IDE, it's showing just fine, but from the Binary file the IDE produces, it is not. Any idea?

This is an example when I have file video.jpg in folder imgs and changing image in a window of class MainJFrame.

You can set this directly in NetBeans properties. You have to open window of iconImage property and then choose to "set property using "custom code"".
There's no difference, but it looks nicer, because then you have your code in the NetBeans generated code.

What about web start?

I am able to get the icon to change in a regular java application by following these instructions. I have a folder "Images" in the "src" directory and everything works for the java application as is.

However...when I switch the application to enable java web start, I am able to build the application as usual, but when I go to run the application I get an error. I can toggle back and forth between "<default config"> and "Web Start" in the drop down menu on the main netbeans page (just to the left of the build hammer) and the app correspondingly works/doesn't work. In the "web start" mode, the error is clearly related to the image.

So...do I have to copy that Image directory somwhere where the web start application can find/use it?