Update FlatRadioButtonUI.java

The method applyStyleProperty of class FlatRadioButtonUI currently styles the variable icon, a field of the parent class BasicRadioButtonUI and the default icon which is set with UIManager.getIcon in method installDefaults. 
So the wrong icon is styled if someone subclasses FlatRadioBoxIcon or FlatCheckBoxIcon and sets this as the new icon for a JRadioButton or JCheckBox instance. (An example why someone would do so is shown in issue #413).
With this change styling takes account of the current icon of a JRadioButton or JCheckBox.
This commit is contained in:
daWoife
2025-11-15 11:37:18 +01:00
committed by GitHub
parent d4827b6ddf
commit 7ebc1b27c1

View File

@@ -203,10 +203,15 @@ public class FlatRadioButtonUI
protected Object applyStyleProperty( AbstractButton b, String key, Object value ) {
// style icon
if( key.startsWith( "icon." ) ) {
if( !(icon instanceof FlatCheckBoxIcon) )
Icon styleIcon = b.getIcon();
if (styleIcon == null)
styleIcon = icon;
if( !(styleIcon instanceof FlatCheckBoxIcon) )
return new UnknownStyleException( key );
if( iconShared ) {
if( styleIcon == icon && iconShared ) {
icon = FlatStylingSupport.cloneIcon( icon );
iconShared = false;
}