javamacosiconsdock

How do you change the Dock Icon of a Java program?


How can I change the Dock Icon of a program, in Java, on the Macintosh platform? I have heard about using Apple's Java library (that provides some sort of extra support on the Mac platform), but I have yet to find some actual examples.


Solution

  • Apple eAWT provides the Application class that allows to change the dock icon of an application.

    import com.apple.eawt.Application;
    ...
    Application application = Application.getApplication();
    Image image = Toolkit.getDefaultToolkit().getImage("icon.png");
    application.setDockIconImage(image);