Button: invoke FlatButtonUI.getForeground(c) also if component is disabled to be consistent with getBackground(c)

This commit is contained in:
Karl Tauber
2020-06-23 12:45:25 +02:00
parent 27eeb0a636
commit b72916187a
2 changed files with 5 additions and 4 deletions

View File

@@ -350,7 +350,7 @@ public class FlatButtonUI
}
}
paintText( g, b, textRect, text, b.isEnabled() ? getForeground( b ) : disabledText );
paintText( g, b, textRect, text, getForeground( b ) );
}
public static void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text, Color foreground ) {
@@ -408,6 +408,9 @@ public class FlatButtonUI
}
protected Color getForeground( JComponent c ) {
if( !c.isEnabled() )
return disabledText;
boolean def = isDefaultButton( c );
return def ? defaultForeground : c.getForeground();
}

View File

@@ -206,9 +206,7 @@ public class FlatToggleButtonUI
@Override
protected Color getForeground( JComponent c ) {
ButtonModel model = ((AbstractButton)c).getModel();
if( model.isSelected() && !isToolBarButton( c ) )
if( c.isEnabled() && ((AbstractButton)c).isSelected() && !isToolBarButton( c ) )
return selectedForeground;
return super.getForeground( c );