Search code examples
javaswingiconstaskbar

Use different icons in JFrame and Windows taskbar


Is there a way to use different icons on JFrame and Windows taskbar?

When I set JFrame.setIconImage(img) this same image is use as Windows icon. Can I use different icons to the JFrame and Windows taskbar?


Solution

  • I cound not use the suggested solutions because I have jdk 1.5 as requirement ...

    So, I did this:

    public void setAppIcons(JFrame frame) {
        List<Image> images = new ArrayList<Image>();
        images.add(getImage(MessageUtils.getString("application.images.icon.app.32")).getImage());
        images.add(getImage(MessageUtils.getString("application.images.icon.app.16")).getImage());
    
        try {
            Class<?> [] types = {java.util.List.class};
            Method method = Class.forName("java.awt.Window").getDeclaredMethod("setIconImages", types);
    
            Object [] parameters = {images};
            method.invoke(frame, parameters);
        } catch (Exception e) {
            frame.setIconImage(images.get(0));
        }       
    }
    

    If the client is running the application in a jre 1.6 or major, the application will pick the image list to set ...

    Tks for your suggestions.