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?
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?
You can use setIconImages() to provide a list of icons in different sizes. The JRE will select the best available size to use for each use (so a more detailed version can be shown when the icon is displayed in a larger size).
AFAIK there is no planned way to show different icons for specific uses.
You could make use of setUndecorated(true) and render the windows decorations yourself, but its non-trivial to make this work as intended (due to look&feel). A hacky solution could be to find your way trough the window peer components (with the JDK source + reflection at runtime) and supply a different icon to one or the other peer component. Again this may require code specific to the active L&F.
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.