TabbedPane: support background color for selected tabs

This commit is contained in:
Karl Tauber
2019-12-13 23:14:41 +01:00
parent c4183ada11
commit 65fbcedaa4
3 changed files with 15 additions and 2 deletions

View File

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

View File

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

View File

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