Styling: add property change listener only for FlatLaf.style (where possible)

This commit is contained in:
Karl Tauber
2021-06-24 14:05:24 +02:00
parent 551f5fc929
commit 5e5aa17e14
2 changed files with 6 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ import javax.swing.JSeparator;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSeparatorUI; import javax.swing.plaf.basic.BasicSeparatorUI;
import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable; import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable;
/** /**
@@ -110,14 +111,14 @@ public class FlatSeparatorUI
propertyChangeListener = FlatStyleSupport.createPropertyChangeListener( propertyChangeListener = FlatStyleSupport.createPropertyChangeListener(
s, style -> applyStyle( s, this, style ), null ); s, style -> applyStyle( s, this, style ), null );
s.addPropertyChangeListener( propertyChangeListener ); s.addPropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener );
} }
@Override @Override
protected void uninstallListeners( JSeparator s ) { protected void uninstallListeners( JSeparator s ) {
super.uninstallListeners( s ); super.uninstallListeners( s );
s.removePropertyChangeListener( propertyChangeListener ); s.removePropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener );
propertyChangeListener = null; propertyChangeListener = null;
} }

View File

@@ -34,6 +34,7 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI; import javax.swing.plaf.basic.BasicSplitPaneUI;
import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable; import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable;
import com.formdev.flatlaf.ui.FlatStyleSupport.UnknownStyleException; import com.formdev.flatlaf.ui.FlatStyleSupport.UnknownStyleException;
import com.formdev.flatlaf.util.UIScale; import com.formdev.flatlaf.util.UIScale;
@@ -119,14 +120,14 @@ public class FlatSplitPaneUI
super.installListeners(); super.installListeners();
propertyChangeListener = FlatStyleSupport.createPropertyChangeListener( splitPane, this::applyStyle, null ); propertyChangeListener = FlatStyleSupport.createPropertyChangeListener( splitPane, this::applyStyle, null );
splitPane.addPropertyChangeListener( propertyChangeListener ); splitPane.addPropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener );
} }
@Override @Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
splitPane.removePropertyChangeListener( propertyChangeListener ); splitPane.removePropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener );
propertyChangeListener = null; propertyChangeListener = null;
} }