From 5e5aa17e14e30147de8514b67075688f8d5df4d0 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 24 Jun 2021 14:05:24 +0200 Subject: [PATCH] Styling: add property change listener only for `FlatLaf.style` (where possible) --- .../main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java | 5 +++-- .../main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java index e0b5c289..5d8fd01b 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java @@ -28,6 +28,7 @@ import javax.swing.JSeparator; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicSeparatorUI; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable; /** @@ -110,14 +111,14 @@ public class FlatSeparatorUI propertyChangeListener = FlatStyleSupport.createPropertyChangeListener( s, style -> applyStyle( s, this, style ), null ); - s.addPropertyChangeListener( propertyChangeListener ); + s.addPropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener ); } @Override protected void uninstallListeners( JSeparator s ) { super.uninstallListeners( s ); - s.removePropertyChangeListener( propertyChangeListener ); + s.removePropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener ); propertyChangeListener = null; } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java index 5f012cf3..47dfad80 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java @@ -34,6 +34,7 @@ import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneUI; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable; import com.formdev.flatlaf.ui.FlatStyleSupport.UnknownStyleException; import com.formdev.flatlaf.util.UIScale; @@ -119,14 +120,14 @@ public class FlatSplitPaneUI super.installListeners(); propertyChangeListener = FlatStyleSupport.createPropertyChangeListener( splitPane, this::applyStyle, null ); - splitPane.addPropertyChangeListener( propertyChangeListener ); + splitPane.addPropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener ); } @Override protected void uninstallListeners() { super.uninstallListeners(); - splitPane.removePropertyChangeListener( propertyChangeListener ); + splitPane.removePropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener ); propertyChangeListener = null; }