I\'m trying to set the icon image for a Jar file:
setIconImage(new ImageIcon(getClass().getResource(\"logo.png\")).getImage());
When runnin
Just to add my final solution for adding a MacOSX Dock icon in a pure-java application:
public boolean exists(String className)
{
try {
Class.forName( className, false, null );
return true;
}
catch (ClassNotFoundException exception) {
return false;
}
}
public void setIcon( BufferedImage icn )
{
if ( exists( "com.apple.eawt.Application" ) )
{
com.apple.eawt.Application.getApplication().setDockIconImage( icn );
}
}
This silently ensures the class is available and the executes the setDockIconImage()
method. Works very well for me and it does not interfere with other platforms.