ComboBox: added UI property ComboBox.buttonFocusedEditableBackground (issue #1068)

This commit is contained in:
Karl Tauber
2025-12-30 17:36:06 +01:00
parent 0e3cb95791
commit 7680c3a817
8 changed files with 15 additions and 3 deletions

View File

@@ -3,6 +3,8 @@ FlatLaf Change Log
## 3.7.1-SNAPSHOT ## 3.7.1-SNAPSHOT
- ComboBox: Added UI property `ComboBox.buttonFocusedEditableBackground`. (issue
#1068)
- Popup: Fixed scrolling popup painting issue on Windows 10 when a glass pane is - Popup: Fixed scrolling popup painting issue on Windows 10 when a glass pane is
visible and frame is maximized. (issue #1071) visible and frame is maximized. (issue #1071)

View File

@@ -113,6 +113,7 @@ import com.formdev.flatlaf.util.SystemInfo;
* @uiDefault ComboBox.buttonBackground Color optional * @uiDefault ComboBox.buttonBackground Color optional
* @uiDefault ComboBox.buttonEditableBackground Color optional * @uiDefault ComboBox.buttonEditableBackground Color optional
* @uiDefault ComboBox.buttonFocusedBackground Color optional; defaults to ComboBox.focusedBackground * @uiDefault ComboBox.buttonFocusedBackground Color optional; defaults to ComboBox.focusedBackground
* @uiDefault ComboBox.buttonFocusedEditableBackground Color optional; defaults to ComboBox.buttonEditableBackground
* @uiDefault ComboBox.buttonSeparatorWidth int or float optional; defaults to Component.borderWidth * @uiDefault ComboBox.buttonSeparatorWidth int or float optional; defaults to Component.borderWidth
* @uiDefault ComboBox.buttonSeparatorColor Color optional * @uiDefault ComboBox.buttonSeparatorColor Color optional
* @uiDefault ComboBox.buttonDisabledSeparatorColor Color optional * @uiDefault ComboBox.buttonDisabledSeparatorColor Color optional
@@ -147,6 +148,7 @@ public class FlatComboBoxUI
@Styleable protected Color buttonBackground; @Styleable protected Color buttonBackground;
@Styleable protected Color buttonEditableBackground; @Styleable protected Color buttonEditableBackground;
@Styleable protected Color buttonFocusedBackground; @Styleable protected Color buttonFocusedBackground;
/** @since 3.7.1 */ @Styleable protected Color buttonFocusedEditableBackground;
/** @since 2 */ @Styleable protected float buttonSeparatorWidth; /** @since 2 */ @Styleable protected float buttonSeparatorWidth;
/** @since 2 */ @Styleable protected Color buttonSeparatorColor; /** @since 2 */ @Styleable protected Color buttonSeparatorColor;
/** @since 2 */ @Styleable protected Color buttonDisabledSeparatorColor; /** @since 2 */ @Styleable protected Color buttonDisabledSeparatorColor;
@@ -258,6 +260,7 @@ public class FlatComboBoxUI
buttonBackground = UIManager.getColor( "ComboBox.buttonBackground" ); buttonBackground = UIManager.getColor( "ComboBox.buttonBackground" );
buttonFocusedBackground = UIManager.getColor( "ComboBox.buttonFocusedBackground" ); buttonFocusedBackground = UIManager.getColor( "ComboBox.buttonFocusedBackground" );
buttonFocusedEditableBackground = UIManager.getColor( "ComboBox.buttonFocusedEditableBackground" );
buttonEditableBackground = UIManager.getColor( "ComboBox.buttonEditableBackground" ); buttonEditableBackground = UIManager.getColor( "ComboBox.buttonEditableBackground" );
buttonSeparatorWidth = FlatUIUtils.getUIFloat( "ComboBox.buttonSeparatorWidth", FlatUIUtils.getUIFloat( "Component.borderWidth", 1 ) ); buttonSeparatorWidth = FlatUIUtils.getUIFloat( "ComboBox.buttonSeparatorWidth", FlatUIUtils.getUIFloat( "Component.borderWidth", 1 ) );
buttonSeparatorColor = UIManager.getColor( "ComboBox.buttonSeparatorColor" ); buttonSeparatorColor = UIManager.getColor( "ComboBox.buttonSeparatorColor" );
@@ -293,6 +296,7 @@ public class FlatComboBoxUI
buttonBackground = null; buttonBackground = null;
buttonEditableBackground = null; buttonEditableBackground = null;
buttonFocusedBackground = null; buttonFocusedBackground = null;
buttonFocusedEditableBackground = null;
buttonSeparatorColor = null; buttonSeparatorColor = null;
buttonDisabledSeparatorColor = null; buttonDisabledSeparatorColor = null;
buttonArrowColor = null; buttonArrowColor = null;
@@ -587,7 +591,7 @@ public class FlatComboBoxUI
// paint arrow button background // paint arrow button background
if( enabled && !isCellRenderer && arrowButton.isVisible() ) { if( enabled && !isCellRenderer && arrowButton.isVisible() ) {
Color buttonColor = paintButton Color buttonColor = paintButton
? buttonEditableBackground ? (buttonFocusedEditableBackground != null && isPermanentFocusOwner( comboBox ) ? buttonFocusedEditableBackground : buttonEditableBackground)
: (buttonFocusedBackground != null || focusedBackground != null) && isPermanentFocusOwner( comboBox ) : (buttonFocusedBackground != null || focusedBackground != null) && isPermanentFocusOwner( comboBox )
? (buttonFocusedBackground != null ? buttonFocusedBackground : focusedBackground) ? (buttonFocusedBackground != null ? buttonFocusedBackground : focusedBackground)
: buttonBackground; : buttonBackground;

View File

@@ -199,8 +199,9 @@ public class TestFlatStyleableInfo
"disabledForeground", Color.class, "disabledForeground", Color.class,
"buttonBackground", Color.class, "buttonBackground", Color.class,
"buttonFocusedBackground", Color.class,
"buttonEditableBackground", Color.class, "buttonEditableBackground", Color.class,
"buttonFocusedBackground", Color.class,
"buttonFocusedEditableBackground", Color.class,
"buttonSeparatorWidth", float.class, "buttonSeparatorWidth", float.class,
"buttonSeparatorColor", Color.class, "buttonSeparatorColor", Color.class,
"buttonDisabledSeparatorColor", Color.class, "buttonDisabledSeparatorColor", Color.class,

View File

@@ -388,8 +388,9 @@ public class TestFlatStyleableValue
testColor( c, ui, "disabledForeground" ); testColor( c, ui, "disabledForeground" );
testColor( c, ui, "buttonBackground" ); testColor( c, ui, "buttonBackground" );
testColor( c, ui, "buttonFocusedBackground" );
testColor( c, ui, "buttonEditableBackground" ); testColor( c, ui, "buttonEditableBackground" );
testColor( c, ui, "buttonFocusedBackground" );
testColor( c, ui, "buttonFocusedEditableBackground" );
testFloat( c, ui, "buttonSeparatorWidth" ); testFloat( c, ui, "buttonSeparatorWidth" );
testColor( c, ui, "buttonSeparatorColor" ); testColor( c, ui, "buttonSeparatorColor" );
testColor( c, ui, "buttonDisabledSeparatorColor" ); testColor( c, ui, "buttonDisabledSeparatorColor" );

View File

@@ -184,6 +184,7 @@ buttonDisabledArrowColor java.awt.Color
buttonDisabledSeparatorColor java.awt.Color buttonDisabledSeparatorColor java.awt.Color
buttonEditableBackground java.awt.Color buttonEditableBackground java.awt.Color
buttonFocusedBackground java.awt.Color buttonFocusedBackground java.awt.Color
buttonFocusedEditableBackground java.awt.Color
buttonHoverArrowColor java.awt.Color buttonHoverArrowColor java.awt.Color
buttonPressedArrowColor java.awt.Color buttonPressedArrowColor java.awt.Color
buttonSeparatorColor java.awt.Color buttonSeparatorColor java.awt.Color

View File

@@ -235,6 +235,7 @@ ComboBox.buttonDisabledArrowColor #ababab HSL 0 0 67 javax.swing.plaf.C
ComboBox.buttonDisabledSeparatorColor #000088 HSL 240 100 27 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonDisabledSeparatorColor #000088 HSL 240 100 27 javax.swing.plaf.ColorUIResource [UI]
ComboBox.buttonEditableBackground #cccccc HSL 0 0 80 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonEditableBackground #cccccc HSL 0 0 80 javax.swing.plaf.ColorUIResource [UI]
ComboBox.buttonFocusedBackground #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonFocusedBackground #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI]
ComboBox.buttonFocusedEditableBackground #ffff44 HSL 60 100 63 javax.swing.plaf.ColorUIResource [UI]
ComboBox.buttonHighlight #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonHighlight #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
ComboBox.buttonHoverArrowColor #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonHoverArrowColor #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI]
ComboBox.buttonPressedArrowColor #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonPressedArrowColor #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI]

View File

@@ -182,6 +182,7 @@ ComboBox.buttonEditableBackground = #ccc
ComboBox.focusedBackground = #ff8 ComboBox.focusedBackground = #ff8
ComboBox.buttonFocusedBackground = #ff0 ComboBox.buttonFocusedBackground = #ff0
ComboBox.buttonFocusedEditableBackground = #ff4
ComboBox.popupBackground = #ffc ComboBox.popupBackground = #ffc

View File

@@ -226,6 +226,7 @@ ComboBox.buttonDisabledArrowColor
ComboBox.buttonDisabledSeparatorColor ComboBox.buttonDisabledSeparatorColor
ComboBox.buttonEditableBackground ComboBox.buttonEditableBackground
ComboBox.buttonFocusedBackground ComboBox.buttonFocusedBackground
ComboBox.buttonFocusedEditableBackground
ComboBox.buttonHighlight ComboBox.buttonHighlight
ComboBox.buttonHoverArrowColor ComboBox.buttonHoverArrowColor
ComboBox.buttonPressedArrowColor ComboBox.buttonPressedArrowColor