Synthetica V3 - UI-Scaling support(20:30, 27. Sep. 2017)

Some modern displays offer high pixel density - commonly known as Ultra-HD, 4K, 5K or something similar. Without upscaling your application becomes almost unusable because it appears pretty tiny on these displays if not upscaled from the OS. In Synthetica 2.X.X a font scale factor can be set, so your application is still usable. However, for complete UI-scaling support Synthetica V3 is required. Which means all sizes, insets, gaps, dimensions, images, icons, font get scaled depending on the provided scale factor.

UI-scaling is enabled by specifying a percentage scale factor on application startup through the UI-property "Synthetica.scaleFactor".

UIManager.put("Synthetica.scaleFactor", 200);
//UIManager.put("Synthetica.font.scaleFactor", 200);


Regular (without any scale factor)

Regular Screenshot

FontScaleFactor 200
By specifying a font scale factor only font and font based icons of the toolbar will be scaled.

FontScaleFactor 200 Screenshot

ScaleFactor 200
Complete scaling - font, icons, insets, gaps, dimensions, sizes...

ScaleFactor 200 Screenshot


Most scaling is done under the hood, but sometimes you have to specify fixed size values in your application. To make these values scalable too, Synthetica's HiDpi class provides some static helper methods which can be used as value wrapper or replacement for constructors just like in the examples below.

//frame.setSize(new Dimension(800,600));

//JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 20));
JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, HiDpi.scale(10), HiDpi.scale(20)));
//panel.setPreferredSize(new Dimension(400, 300));
panel.setPreferredSize(HiDpi.scaleDimension(400, 300));
//taskPane.setTitleFont(new Font("Dialog", Font.BOLD, 14));
taskPane.setTitleFont(new Font("Dialog", Font.BOLD, HiDpi.scale(14)));
//gbc.insets = new Insets(5,5,5,5);
gbc.insets = HiDpi.scaleInsets(5,5,5,5);


Icon Scaling

Generally icons also have fixed sizes - to make icons scalable the HiDpi class provides the wrapper method #createIcon(Icon icon) and additional methods (#createIcon(Class<?> resourceBase, String... fileNames)) for high resolution support. By specifying at least one high resolution icon, multi-resolution support is enabled. Which means depending on the size the best matching icon will be used automatically.

// use HiDpi wrapper to make an icon scalable
Icon myIcon = new ImageIcon(getClass().getResource("/resources/myIcon.png"));

// can be simplified with line below
button.setIcon(HiDpi.createIcon(getClass(), "/resources/myIcon.png"));

// by adding a high resolution icon, multi-resolution support is enabled
button.setIcon(HiDpi.createIcon(getClass(), "/resources/myIcon.png", "/resources/[email protected]"));

SyntheticaAddons V3 also provides a font based icon library set with around 7.000 free icons. These vector icons are already scalable and don't have to be wrapped. Our IconFontBrowser application helps you to find the needed icon and generates the code for using within your own application.

IconFontBrowser Tool

IconFontBrowser Screenshot


Swing UI-Scaling

As you maybe know since Java 9 you can also enable UI-scaling with the system property sun.java2d.uiScale and Swing UI-scaling is automatically enabled on high-resolution displays. However, we recommend to use Synthetica's UI-scaling feature because the setting can be stored in the XML-file of a theme and the scaling results are generally better. By using Swing UI-scaling some artifacts can appear, so it's actually recommended to disable Swing UI-Scaling in high-resolution/HiDpi environments by setting the system property sun.java2d.uiScale.enabled to false.

Product Links
Synthetica V3 - High-Resolution/HiDpi support
Synthetica UI-Scaling In Detail
Synthetica/SyntheticaAddons V3
Synthetica Look And Feel
Synthetica Download
SyntheticaAddons Download
SyntheticaAddons Demos