I am trying to add an icon to a JFrame titlebar in OS X. The code I have used is:
ImageIcon icon = new ImageIcon("src/images/theIcon.gif");
System.out.println("Icon dimensions are " + icon.getIconWidth() + " by " + icon.getIconHeight());
frame.setIconImage(icon.getImage());
No icon shows up, and the console output shows the correct dimensions for the image.
There must be something wrong with the expression setIconImage(icon.getImage())
, but I can't see what.
I am on Mac OS 10.8.2, running Java SE 6 and Eclipse Juno. Actually, I'm wondering if this is an OS X issue.