ToggleButton: tab style buttons now respect explicitly set background color

This commit is contained in:
Karl Tauber
2021-01-13 17:52:05 +01:00
parent b49a498f9c
commit 15328b4fd7
2 changed files with 11 additions and 2 deletions

View File

@@ -30,6 +30,8 @@ FlatLaf Change Log
- Button and ToggleButton: ToolBar buttons now respect explicitly set background
color. If no background color is set, then the button background is not
painted anymore. (issue #191)
- ToggleButton: Tab style buttons (client property `JButton.buttonType` is
`tab`) now respect explicitly set background color.
- TabbedPane: Fixed `IndexOutOfBoundsException` when using tooltip text on close
buttons and closing last/rightmost tab. (issue #235)
- Extras: Added missing export of package

View File

@@ -146,10 +146,17 @@ public class FlatToggleButtonUI
int height = c.getHeight();
int width = c.getWidth();
boolean selected = ((AbstractButton)c).isSelected();
Color enabledColor = selected ? clientPropertyColor( c, TAB_BUTTON_SELECTED_BACKGROUND, tabSelectedBackground ) : null;
// use component background if explicitly set
if( enabledColor == null ) {
Color bg = c.getBackground();
if( isCustomBackground( bg ) )
enabledColor = bg;
}
// paint background
Color background = buttonStateColor( c,
selected ? clientPropertyColor( c, TAB_BUTTON_SELECTED_BACKGROUND, tabSelectedBackground ) : null,
Color background = buttonStateColor( c, enabledColor,
null, tabFocusBackground, tabHoverBackground, null );
if( background != null ) {
g.setColor( background );