Set the small top-left icon on a FrameTag(s): AWT


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. With 1.5, you can use a PNG or JPG file.

You set the icon with :

frame.setIconImage(Toolkit.getDefaultToolkit().getImage("myIcon.gif"));
To get the image from a Jar instead, do :
frame.setIconImage
  (Toolkit.getDefaultToolkit()
     .getImage(getClass().
         getResource("images/myIcon.gif")));
or
frame.setIconImage(
     new ImageIcon(
         YourApp.class.getResource("logo.png")
     ).getImage()
);


blog comments powered by Disqus