Skip to content

Commit

Permalink
Button and ToggleButton: selected buttons did not use explicitly set …
Browse files Browse the repository at this point in the history
…foreground color (issue 756)
  • Loading branch information
DevCharly committed Oct 29, 2023
1 parent 9602b19 commit 471ec1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,15 @@ public static Color buttonStateColor( Component c, Color enabledColor, Color dis
}

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),
Expand All @@ -740,7 +741,7 @@ protected Color getForeground( JComponent c ) {
// toolbar button
if( toolBarButton ) {
return buttonStateColor( c,
c.getForeground(),
fg,
disabledText,
null,
toolbarHoverForeground,
Expand All @@ -751,7 +752,7 @@ protected Color getForeground( JComponent c ) {
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 );
}
Expand Down

0 comments on commit 471ec1d

Please sign in to comment.