Search code examples
javaiconstaskbar

App Icon is not sharp


Hi I am making an app in Java but the icon in the taskbar is blurry and big unlike other applications as Android studio, Netbeans, Chrome. I am using Adobe Illustrator for making icons with size of 96x96 px. Any ideas?


Solution

  • Most likely you set the icon of your window with Window.setIconImage(Image image) method.

    Note that there is another method: Window.SetIconImages(List icons). Since different platforms display application icons in different sizes (and the resize algorithm is often a bad one), you should use this to supply your icon in differnet sizes, and the size which best fits into the required size will be used.

    Quoting from the javadoc:

    Depending on the platform capabilities one or several images of different dimensions will be used as the window's icon.

    The icons list is scanned for the images of most appropriate dimensions from the beginning. If the list contains several images of the same size, the first will be used.

    Example:

    List<Image> icons = new ArrayList<Image>();
    icons.add(new ImageIcon("icon16x16.png").getImage());
    icons.add(new ImageIcon("icon32x32.png").getImage());
    icons.add(new ImageIcon("icon48x48.png").getImage());
    icons.add(new ImageIcon("icon64x64.png").getImage());
    window.setIconImages(icons);