Search This Blog

Wednesday, December 17, 2008

Add an application icon when inheritance comes from org.jdesktop.application.FrameView

If you are using Netbeans to generate your components and if you have the next type of constructor


public Main(SingleFrameApplication app)
{
initComponents();
}



just add the next code after calling initComponents

java.awt.Image im = java.awt.Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/.../feed-icon.png"));
getFrame().setIconImage(im);


(Of course correct the path to the file inside the package.)

Now your application should display the icon in the top of the window (only tested in Microsoft Windows)