JDialog - how to change icon

I want to change the JDialog icon (replace the standard java cup) I can do this as follows:

ImageIcon img = new ImageIcon(OuterClass.class.getResource("fileThatWorks.jpg"));
myJDialog.setIconImage(img.getImage());

Howerver, when I replaced the fileThatWorks.jpgcode image.ico, stopped working. I tried to convert mine image.icoto image.jpg, but it was not pasted.

What is wrong with my approach? Why does it work for some * jpg files, but it does not work for * ico files?

+3
source share
1 answer

The ImageIcon API claims that the supported types are JPEG and GIF. Not too sure of a workaround for this.

+3
source

All Articles