Jump to Real's How-to Main page

Set the small top-left icon on a Frame

There is a bug in JDK1.0.2 for Windows, so you are stuck with the JAVA coffee cup.

In JDK1.1, this is fixed. You have to use a GIF file (not ICO file!). The GIF dimension should be 16x16.

You set the icon (probably in the Frame constructor) with :

setIconImage(Toolkit.getDefaultToolkit().getImage("myIcon.gif"));
To get the image from a Jar instead, do :
setIconImage
  (Toolkit.getDefaultToolkit()
     .getImage(getClass().
         getResource("images/myIcon.gif")));

If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]