Button and ToggleButton: selected buttons did not use explicitly set foreground color (issue #756)

This commit is contained in:
Karl Tauber
2023-10-29 20:15:02 +01:00
parent 9602b191a9
commit 808f5a6381
2 changed files with 7 additions and 4 deletions

View File

@@ -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)

View File

@@ -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 );
}