I downloaded and installed the latest version of early access Java 9, and was glad to find that the Java Swing application on Windows now displays components in the correct size. My clients with HiDPI displays no longer need to use my app with half the intended width and height.
However, I noticed that in my Swing app, my own icons simply scale to double the width and height, making them look like jaggy.
I have a complete set of all the icons, both with the usual size (for example, foobar.png) and with double width / height (for example, foobar@2x.png ). I use Apple's naming conventions.
How would I like to get Java 9 to easily find and use the higher resolution version of the image when it is available, without having to manually encode it?
Sample code always makes the question clearer, just as Java 9 has an icon class with several permissions that I could use to compile and run the following code?
import javax.swing.*; public class ScratchSpace { public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame("I work in HiDPI!");
I think there should be such a class, but I cannot find it.
source share