Skip to content

Commit

Permalink
added system property flatlaf.updateUIOnSystemFontChange to allow d…
Browse files Browse the repository at this point in the history
…isabling automatic UI update when system font changes (issue #580)
  • Loading branch information
DevCharly committed Aug 24, 2022
1 parent 16f3f9e commit 30132aa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java
Expand Up @@ -276,6 +276,9 @@ public void initialize() {
}
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();
Expand Down
Expand Up @@ -16,6 +16,7 @@

package com.formdev.flatlaf;

import javax.swing.SwingUtilities;
import com.formdev.flatlaf.util.UIScale;

/**
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 30132aa

Please sign in to comment.