Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Low quality icon in taskbar of a Stage. JavaFX

Tags:

java

javafx

Why Stage icon so low quality? The original image is much better. How to fix it?

I used this code to setting image as stage icon:

stage.getIcons().add(new Image("/res/app_icon.png"));

Screenshot:
Screenshot

Original icon:
Original icon

like image 565
Nazariy Demyanovskyi Avatar asked Mar 30 '15 20:03

Nazariy Demyanovskyi


1 Answers

Update

Unfortunately the implementation of the icon chooser in JavaFX 8 does not always choose the best icon size for the application from the list of available icons.

See:

  • JDK-8091186 Windows 7 taskbar icon is blurry.
  • JDK-8087459 Ugly icon in Windows task bar.

The issues are (currently) scheduled to be addressed in Java 9.

Some comments on those issues are:

Indeed, Glass currently supports assigning only one icon for a window, it won't allow one to assign a set of differently sized icons. This feature needs to be implemented in Glass.

--

I have noticed that when setting multiple icons, only the last one in the list returned by getIcons() is used. It doesn't matter if other icons, with better resolutions are in the list.

If you provide a list of icons of different sizes, try putting the size you expect to be used most last in the list (perhaps order the list from smallest to largest or place a 48x48 icon, which is the size used in the quick launch area on Windows 7, as the last or only element in the list). Unfortunately, I do not have access to a Windows machine to test the best icon size for that platform.


Icon Guidelines (but be aware of the information in the update above):

  • Provide a set of high quality icons of different sizes to the list returned from stage.getIcons().
  • The best fit size will be chosen by the runtime.
  • Use standard icon sizes which most operating systems can work with without further scaling (for instance item size is a power of two or 48x48).
  • Use high quality source images (the original source image in your question seems a bit blurry to me).
  • For very small icons, sometimes a pure scale of a larger icon to a smaller size is not best. Sometimes it is best for the icon designer to clean up and remove intricate details from the small icon, which might be OK in a larger icon - see the discussion on icon size on Pushing Pixels to help understand why.
  • Info on what icon sizes are used by what OSes is in this icon handbook.

stage.getIcons().addAll(
    new Image("/res/app_icon64x64.png"),
    new Image("/res/app_icon32x32.png"),
    new Image("/res/app_icon16x16.png")
);

A great source of high quality icons in a variety of sizes is http://www.iconarchive.com, for example this refresh icon.

like image 159
jewelsea Avatar answered Nov 10 '22 00:11

jewelsea