Button and ToggleButton: support disabled background color (issue #112)

This commit is contained in:
Karl Tauber
2020-06-15 23:34:21 +02:00
parent fd99af5fe6
commit dffe4f4451
3 changed files with 12 additions and 1 deletions

View File

@@ -1,6 +1,13 @@
FlatLaf Change Log
==================
## Unreleased
- Button and ToggleButton: Support disabled background color (use UI values
`Button.disabledBackground` and `ToggleButton.disabledBackground`). (issue
#112)
## 0.36
- ScrollBar: Made styling more flexible by supporting insets and arc for track

View File

@@ -67,6 +67,7 @@ import com.formdev.flatlaf.util.UIScale;
* @uiDefault Button.focusedBackground Color optional
* @uiDefault Button.hoverBackground Color optional
* @uiDefault Button.pressedBackground Color optional
* @uiDefault Button.disabledBackground Color optional
* @uiDefault Button.disabledText Color
* @uiDefault Button.default.background Color
* @uiDefault Button.default.startBackground Color optional; if set, a gradient paint is used and Button.default.background is ignored
@@ -97,6 +98,7 @@ public class FlatButtonUI
protected Color focusedBackground;
protected Color hoverBackground;
protected Color pressedBackground;
protected Color disabledBackground;
protected Color disabledText;
protected Color defaultBackground;
@@ -142,6 +144,7 @@ public class FlatButtonUI
focusedBackground = UIManager.getColor( prefix + "focusedBackground" );
hoverBackground = UIManager.getColor( prefix + "hoverBackground" );
pressedBackground = UIManager.getColor( prefix + "pressedBackground" );
disabledBackground = UIManager.getColor( prefix + "disabledBackground" );
disabledText = UIManager.getColor( prefix + "disabledText" );
if( UIManager.getBoolean( "Button.paintShadow" ) ) {
@@ -356,7 +359,7 @@ public class FlatButtonUI
protected Color getBackground( JComponent c ) {
if( !c.isEnabled() )
return null;
return disabledBackground;
// toolbar button
if( isToolBarButton( c ) ) {

View File

@@ -50,6 +50,7 @@ import com.formdev.flatlaf.util.UIScale;
* @uiDefault ToggleButton.startBackground Color optional; if set, a gradient paint is used and ToggleButton.background is ignored
* @uiDefault ToggleButton.endBackground Color optional; if set, a gradient paint is used
* @uiDefault ToggleButton.pressedBackground Color
* @uiDefault ToggleButton.disabledBackground Color optional
* @uiDefault ToggleButton.disabledText Color
* @uiDefault ToggleButton.toolbar.hoverBackground Color
* @uiDefault ToggleButton.toolbar.pressedBackground Color