diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToggleButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToggleButtonUI.java index b3ef3a5a..9859b138 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToggleButtonUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToggleButtonUI.java @@ -78,8 +78,11 @@ import com.formdev.flatlaf.util.UIScale; * @uiDefault ToggleButton.tab.underlineColor Color * @uiDefault ToggleButton.tab.disabledUnderlineColor Color * @uiDefault ToggleButton.tab.selectedBackground Color optional + * @uiDefault ToggleButton.tab.selectedForeground Color optional * @uiDefault ToggleButton.tab.hoverBackground Color + * @uiDefault ToggleButton.tab.hoverForeground Color optional * @uiDefault ToggleButton.tab.focusBackground Color + * @uiDefault ToggleButton.tab.focusForeground Color optional * * * @author Karl Tauber @@ -91,8 +94,11 @@ public class FlatToggleButtonUI @Styleable(dot=true) protected Color tabUnderlineColor; @Styleable(dot=true) protected Color tabDisabledUnderlineColor; @Styleable(dot=true) protected Color tabSelectedBackground; + /** @since 2.3 */ @Styleable(dot=true) protected Color tabSelectedForeground; @Styleable(dot=true) protected Color tabHoverBackground; + /** @since 2.3 */ @Styleable(dot=true) protected Color tabHoverForeground; @Styleable(dot=true) protected Color tabFocusBackground; + /** @since 2.3 */ @Styleable(dot=true) protected Color tabFocusForeground; private boolean defaults_initialized = false; @@ -125,8 +131,11 @@ public class FlatToggleButtonUI tabUnderlineColor = UIManager.getColor( "ToggleButton.tab.underlineColor" ); tabDisabledUnderlineColor = UIManager.getColor( "ToggleButton.tab.disabledUnderlineColor" ); tabSelectedBackground = UIManager.getColor( "ToggleButton.tab.selectedBackground" ); + tabSelectedForeground = UIManager.getColor( "ToggleButton.tab.selectedForeground" ); tabHoverBackground = UIManager.getColor( "ToggleButton.tab.hoverBackground" ); + tabHoverForeground = UIManager.getColor( "ToggleButton.tab.hoverForeground" ); tabFocusBackground = UIManager.getColor( "ToggleButton.tab.focusBackground" ); + tabFocusForeground = UIManager.getColor( "ToggleButton.tab.focusForeground" ); defaults_initialized = true; } @@ -231,4 +240,19 @@ public class FlatToggleButtonUI } else super.paintBackground( g, c ); } + + @Override + protected Color getForeground( JComponent c ) { + if( isTabButton( c ) ) { + if( !c.isEnabled() ) + return disabledText; + + if( tabSelectedForeground != null && ((AbstractButton)c).isSelected() ) + return tabSelectedForeground; + + return buttonStateColor( c, c.getForeground(), disabledText, + tabFocusForeground, tabHoverForeground, null ); + } else + return super.getForeground( c ); + } } diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index eaf3b1d9..5050ca80 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -829,6 +829,7 @@ ToggleButton.tab.underlineHeight = 2 ToggleButton.tab.underlineColor = $TabbedPane.underlineColor ToggleButton.tab.disabledUnderlineColor = $TabbedPane.disabledUnderlineColor ToggleButton.tab.selectedBackground = $?TabbedPane.selectedBackground +ToggleButton.tab.selectedForeground = $?TabbedPane.selectedForeground ToggleButton.tab.hoverBackground = $TabbedPane.hoverColor ToggleButton.tab.focusBackground = $TabbedPane.focusColor diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java index 7566c31f..94f853e3 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java @@ -875,8 +875,11 @@ public class TestFlatStyleableInfo "tab.underlineColor", Color.class, "tab.disabledUnderlineColor", Color.class, "tab.selectedBackground", Color.class, + "tab.selectedForeground", Color.class, "tab.hoverBackground", Color.class, - "tab.focusBackground", Color.class + "tab.hoverForeground", Color.class, + "tab.focusBackground", Color.class, + "tab.focusForeground", Color.class ); // FlatToggleButtonUI extends FlatButtonUI diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java index 398331c5..6c7c431a 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java @@ -1085,8 +1085,11 @@ public class TestFlatStyling ui.applyStyle( b, "tab.underlineColor: #fff" ); ui.applyStyle( b, "tab.disabledUnderlineColor: #fff" ); ui.applyStyle( b, "tab.selectedBackground: #fff" ); + ui.applyStyle( b, "tab.selectedForeground: #fff" ); ui.applyStyle( b, "tab.hoverBackground: #fff" ); + ui.applyStyle( b, "tab.hoverForeground: #fff" ); ui.applyStyle( b, "tab.focusBackground: #fff" ); + ui.applyStyle( b, "tab.focusForeground: #fff" ); } @Test diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt index 2a3ecbad..1b86abb8 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt @@ -1314,8 +1314,11 @@ ToggleButton.selectedForeground #000000 HSL 0 0 0 javax.swing.plaf.Col ToggleButton.shadow #a0a0a0 HSL 0 0 63 javax.swing.plaf.ColorUIResource [UI] ToggleButton.tab.disabledUnderlineColor #7a7a7a HSL 0 0 48 javax.swing.plaf.ColorUIResource [UI] ToggleButton.tab.focusBackground #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] +ToggleButton.tab.focusForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ToggleButton.tab.hoverBackground #eeeeee HSL 0 0 93 javax.swing.plaf.ColorUIResource [UI] -ToggleButton.tab.selectedBackground #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI] +ToggleButton.tab.hoverForeground #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI] +ToggleButton.tab.selectedBackground #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI] +ToggleButton.tab.selectedForeground #00aaff HSL 200 100 50 javax.swing.plaf.ColorUIResource [UI] ToggleButton.tab.underlineColor #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI] ToggleButton.tab.underlineHeight 2 ToggleButton.textIconGap 4 diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties index 43999d22..4bc02ecc 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties @@ -454,6 +454,11 @@ ToggleButton.toolbar.selectedForeground = #800 ToggleButton.toolbar.disabledSelectedBackground = #ccc ToggleButton.toolbar.disabledSelectedForeground = #866 +ToggleButton.tab.selectedBackground = #080 +ToggleButton.tab.selectedForeground = #fff +ToggleButton.tab.hoverForeground = #00f +ToggleButton.tab.focusForeground = #080 + #---- ToolBar ---- diff --git a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt index 84e62024..166e07ca 100644 --- a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt +++ b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt @@ -1034,8 +1034,11 @@ ToggleButton.selectedForeground ToggleButton.shadow ToggleButton.tab.disabledUnderlineColor ToggleButton.tab.focusBackground +ToggleButton.tab.focusForeground ToggleButton.tab.hoverBackground +ToggleButton.tab.hoverForeground ToggleButton.tab.selectedBackground +ToggleButton.tab.selectedForeground ToggleButton.tab.underlineColor ToggleButton.tab.underlineHeight ToggleButton.textIconGap