diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b753d68..c90fdec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ FlatLaf Change Log ================== +## Unreleased + +- TabbedPane: Support background color for selected tabs. + + ## 0.21 - ScrollBar: Show decrease/increase arrow buttons if client property diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java index e0746afb..a7e92249 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java @@ -53,6 +53,7 @@ import com.formdev.flatlaf.FlatLaf; * @uiDefault TabbedPane.foreground Color * @uiDefault TabbedPane.shadow Color used for scroll arrows and cropped line * @uiDefault TabbedPane.disabledForeground Color + * @uiDefault TabbedPane.selectedBackground Color optional * @uiDefault TabbedPane.selectedForeground Color * @uiDefault TabbedPane.underlineColor Color * @uiDefault TabbedPane.disabledUnderlineColor Color @@ -73,6 +74,7 @@ public class FlatTabbedPaneUI extends BasicTabbedPaneUI { protected Color disabledForeground; + protected Color selectedBackground; protected Color selectedForeground; protected Color underlineColor; protected Color disabledUnderlineColor; @@ -95,6 +97,7 @@ public class FlatTabbedPaneUI super.installDefaults(); disabledForeground = UIManager.getColor( "TabbedPane.disabledForeground" ); + selectedBackground = UIManager.getColor( "TabbedPane.selectedBackground" ); selectedForeground = UIManager.getColor( "TabbedPane.selectedForeground" ); underlineColor = UIManager.getColor( "TabbedPane.underlineColor" ); disabledUnderlineColor = UIManager.getColor( "TabbedPane.disabledUnderlineColor" ); @@ -124,6 +127,7 @@ public class FlatTabbedPaneUI super.uninstallDefaults(); disabledForeground = null; + selectedBackground = null; selectedForeground = null; underlineColor = null; disabledUnderlineColor = null; @@ -262,7 +266,9 @@ public class FlatTabbedPaneUI ? hoverColor : (enabled && isSelected && tabPane.hasFocus() ? focusColor - : tabPane.getBackgroundAt( tabIndex )) ); + : (selectedBackground != null && enabled && isSelected + ? selectedBackground + : tabPane.getBackgroundAt( tabIndex ))) ); g.fillRect( x, y, w, h ); } @@ -334,7 +340,7 @@ public class FlatTabbedPaneUI } /** - * Actually does the nearly the same as super.paintContentBorder() but + * Actually does nearly the same as super.paintContentBorder() but * - not using UIManager.getColor("TabbedPane.contentAreaColor") to be GUI builder friendly * - not invoking paintContentBorder*Edge() methods * - repaint selection 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 e63f18c3..0138358f 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 @@ -229,6 +229,8 @@ SplitPaneDivider.oneTouchHoverArrowColor=#ff0000 #---- TabbedPane ---- TabbedPane.disabledForeground=#777777 +TabbedPane.selectedBackground=#0f0 +TabbedPane.selectedForeground=#00f TabbedPane.underlineColor=#4A88C7 TabbedPane.disabledUnderlineColor=#7a7a7a TabbedPane.hoverColor=#eeeeee