diff --git a/CHANGELOG.md b/CHANGELOG.md index f5ef3ece..470125e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ FlatLaf Change Log #### Fixed bugs +- Button and ToggleButton: Selected buttons did not use explicitly set + foreground color. (issue 756) - Table: Switching theme looses table grid and intercell spacing. (issues #733 and #750) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java index 6ff9c789..43be898c 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java @@ -721,14 +721,15 @@ public class FlatButtonUI } protected Color getForeground( JComponent c ) { + Color fg = c.getForeground(); boolean toolBarButton = isToolBarButton( c ) || isBorderlessButton( c ); // selected state if( ((AbstractButton)c).isSelected() ) { return buttonStateColor( c, toolBarButton - ? (toolbarSelectedForeground != null ? toolbarSelectedForeground : c.getForeground()) - : selectedForeground, + ? (toolbarSelectedForeground != null ? toolbarSelectedForeground : fg) + : (isCustomForeground( fg ) ? fg : selectedForeground), toolBarButton ? (toolbarDisabledSelectedForeground != null ? toolbarDisabledSelectedForeground : disabledText) : (disabledSelectedForeground != null ? disabledSelectedForeground : disabledText), @@ -740,7 +741,7 @@ public class FlatButtonUI // toolbar button if( toolBarButton ) { return buttonStateColor( c, - c.getForeground(), + fg, disabledText, null, toolbarHoverForeground, @@ -751,7 +752,7 @@ public class FlatButtonUI return buttonStateColor( c, getForegroundBase( c, def ), disabledText, - isCustomForeground( c.getForeground() ) ? null : (def ? defaultFocusedForeground : focusedForeground), + isCustomForeground( fg ) ? null : (def ? defaultFocusedForeground : focusedForeground), def ? defaultHoverForeground : hoverForeground, def ? defaultPressedForeground : pressedForeground ); }