diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ec1db4c..2435529e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ FlatLaf Change Log #### Fixed bugs +- Button: Fixed background and foreground colors for `borderless` and + `toolBarButton` style default buttons (`JButton.isDefaultButton()` is `true`). + (issue #947) - FileChooser: Improved performance when navigating to large directories with thousands of files. (issue #953) - PopupFactory: Fixed NPE on Windows 10 when `owner` is `null`. (issue #952) 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 41691c1b..db9f6838 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 @@ -653,7 +653,8 @@ public class FlatButtonUI } protected Color getBackground( JComponent c ) { - boolean toolBarButton = isToolBarButton( c ) || isBorderlessButton( c ); + boolean def = isDefaultButton( c ); + boolean toolBarButton = !def && (isToolBarButton( c ) || isBorderlessButton( c )); // selected state if( ((AbstractButton)c).isSelected() ) { @@ -681,7 +682,6 @@ public class FlatButtonUI toolbarPressedBackground ); } - boolean def = isDefaultButton( c ); return buttonStateColor( c, getBackgroundBase( c, def ), disabledBackground, @@ -733,7 +733,8 @@ public class FlatButtonUI protected Color getForeground( JComponent c ) { Color fg = c.getForeground(); - boolean toolBarButton = isToolBarButton( c ) || isBorderlessButton( c ); + boolean def = isDefaultButton( c ); + boolean toolBarButton = !def && (isToolBarButton( c ) || isBorderlessButton( c )); // selected state if( ((AbstractButton)c).isSelected() ) { @@ -759,7 +760,6 @@ public class FlatButtonUI toolbarPressedForeground ); } - boolean def = isDefaultButton( c ); return buttonStateColor( c, getForegroundBase( c, def ), disabledText,