According to these articles:
http://news.kynosarges.org/2015/06/29/javafx-dpi-scaling-fixed
https://twitter.com/michaelsamarin/status/729234779292483584
Java 9 should support high DPI displays (automatic DPI scaling) in Swing. I have tested it on the last version of Java 9 Early Access + on Zulu 9 and it works and looks really great.
I was unable to solve only one thing - high resolution/retina image loading.
According to articles (links) above and below it should use an Apple name convention (@2x):
image.png
, [email protected]
, [email protected]
, etc.
I tested these loading methods:
Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("something/image.png"));
and
ImageIO.read(getClass().getResource("/something/image.png"));
But none of these works (the only base image was loaded and blurred).
According to this:
The first method should be promising.
Has anyone any experiences with this (using Swing or even JavaFX)? I'm not sure if I'm doing something wrong or this feature is not implemented to the current pre-release version of Java 9 sofar.
Update:
It should be possible:
I've also tried following naming conventions (described here):
Windows : image.scale-<dpi-value>.png (image.scale-140.png)
Linux : image.java-scale2x.png
Mac : [email protected] and image.java-scale2x.png
However, I cannot find any working solution or official information. I don't get it - hdpi displays are common today and Java applications look like s... on them.
url
from JavaFX style, not when using programmatic API to load the image in generic way. – NostrilMultiResolutionImage
, it provides access to the images, i've not seen an examples, so I'm unsure if implementations ofMultiResolutionImage
are required (or expeceted) to use the "best fit" image automatically – GabriellaBaseMultiResolutionImage
? – TaxBaseMultiResolutionImage
with a manual (in code) filling by images works. But I would like to have the application compatible with older Java versions (ok - It would be manageable using some reflection mess, but I would like to leave this as the last resort). – CrosslandAbstractMultiResolutionImage
lists an example in the javadoc – CheneeBaseMultiResolutionImage
. – Crossland