mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06:00
Styling: use FlatStyleSupport.createPropertyChangeListener() where possible/useful
This commit is contained in:
@@ -28,7 +28,6 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -107,15 +106,8 @@ public class FlatSeparatorUI
|
||||
protected void installListeners( JSeparator s ) {
|
||||
super.installListeners( s );
|
||||
|
||||
propertyChangeListener = e -> {
|
||||
switch( e.getPropertyName() ) {
|
||||
case FlatClientProperties.STYLE:
|
||||
applyStyle( s, this, e.getNewValue() );
|
||||
s.revalidate();
|
||||
s.repaint();
|
||||
break;
|
||||
}
|
||||
};
|
||||
propertyChangeListener = FlatStyleSupport.createPropertyChangeListener(
|
||||
s, style -> applyStyle( s, this, style ), null );
|
||||
s.addPropertyChangeListener( propertyChangeListener );
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicSliderUI;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable;
|
||||
import com.formdev.flatlaf.util.Graphics2DProxy;
|
||||
import com.formdev.flatlaf.util.HiDPIUtils;
|
||||
@@ -185,18 +184,8 @@ public class FlatSliderUI
|
||||
|
||||
@Override
|
||||
protected PropertyChangeListener createPropertyChangeListener( JSlider slider ) {
|
||||
PropertyChangeListener superListener = super.createPropertyChangeListener( slider );
|
||||
return e -> {
|
||||
superListener.propertyChange( e );
|
||||
|
||||
switch( e.getPropertyName() ) {
|
||||
case FlatClientProperties.STYLE:
|
||||
applyStyle( e.getNewValue() );
|
||||
slider.revalidate();
|
||||
slider.repaint();
|
||||
break;
|
||||
}
|
||||
};
|
||||
return FlatStyleSupport.createPropertyChangeListener( slider, this::applyStyle,
|
||||
super.createPropertyChangeListener( slider ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,6 @@ 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;
|
||||
@@ -117,15 +116,7 @@ public class FlatSplitPaneUI
|
||||
protected void installListeners() {
|
||||
super.installListeners();
|
||||
|
||||
propertyChangeListener = e -> {
|
||||
switch( e.getPropertyName() ) {
|
||||
case FlatClientProperties.STYLE:
|
||||
applyStyle( e.getNewValue() );
|
||||
splitPane.revalidate();
|
||||
splitPane.repaint();
|
||||
break;
|
||||
}
|
||||
};
|
||||
propertyChangeListener = FlatStyleSupport.createPropertyChangeListener( splitPane, this::applyStyle, null );
|
||||
splitPane.addPropertyChangeListener( propertyChangeListener );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user