How to change the default icon on a Java Frame

When you create a Java frame, it usually comes with the default Java icon on the window title.

It is not a bad icon, but you might want to customize that portion after a while.

All you need to do is place this code snippet on the initialization part of your frame:


this.setIconImage(Toolkit.getDefaultToolkit().getImage("./media/network.png"));


I've simply placed a .png image on a folder called "media" on the root of my project.

Have fun.