added system property flatlaf.updateUIOnSystemFontChange to allow disabling automatic UI update when system font changes (issue #580)

This commit is contained in:
Karl Tauber
2022-08-24 19:32:38 +02:00
parent 16f3f9e6ff
commit 30132aa6b0
3 changed files with 20 additions and 0 deletions

View File

@@ -10,6 +10,8 @@ FlatLaf Change Log
- Native window decorations (Windows 10/11 only): Added client property to mark
components in embedded menu bar as "caption" (allow moving window). (issue
#569)
- Added system property `flatlaf.updateUIOnSystemFontChange` to allow disabling
automatic UI update when system font changes. (issue #580)
#### Fixed bugs

View File

@@ -276,6 +276,9 @@ public abstract class FlatLaf
}
if( desktopPropertyName != null ) {
desktopPropertyListener = e -> {
if( !FlatSystemProperties.getBoolean( FlatSystemProperties.UPDATE_UI_ON_SYSTEM_FONT_CHANGE, true ) )
return;
String propertyName = e.getPropertyName();
if( desktopPropertyName.equals( propertyName ) || propertyName.equals( desktopPropertyName2 ) )
reSetLookAndFeel();

View File

@@ -16,6 +16,7 @@
package com.formdev.flatlaf;
import javax.swing.SwingUtilities;
import com.formdev.flatlaf.util.UIScale;
/**
@@ -139,6 +140,20 @@ public interface FlatSystemProperties
*/
String USE_TEXT_Y_CORRECTION = "flatlaf.useTextYCorrection";
/**
* Specifies whether FlatLaf updates the UI when the system font changes.
* If {@code true}, {@link SwingUtilities#updateComponentTreeUI(java.awt.Component)}
* gets invoked for all windows if the system font has changed.
* This is the similar to when switching to another look and feel (theme).
* Applications that do not work correctly when switching look and feel,
* should disable this option to avoid corrupted UI.
* <p>
* <strong>Allowed Values</strong> {@code false} and {@code true}<br>
* <strong>Default</strong> {@code true}
* @since 2.5
*/
String UPDATE_UI_ON_SYSTEM_FONT_CHANGE = "flatlaf.updateUIOnSystemFontChange";
/**
* Specifies a directory in which the native FlatLaf library have been extracted.
* The path can be absolute or relative to current application working directory.