Button: fixed background and foreground colors for borderless and toolBarButton style default buttons (JButton.isDefaultButton() is true) (issue #947)

This commit is contained in:
Karl Tauber
2025-01-09 14:38:36 +01:00
parent 8dc6242889
commit a238fd4505
2 changed files with 7 additions and 4 deletions

View File

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

View File

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