diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e58d802..bb725905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ FlatLaf Change Log ================== +## 3.0-SNAPSHOT + +#### Fixed bugs + +- ComboBox and Spinner: Fixed missing arrow buttons if preferred height is zero. + Minimum width of arrow buttons is 3/4 of default width. + + ## 2.5 #### New features and improvements diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java index 155e9523..fc634119 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java @@ -308,11 +308,14 @@ public class FlatComboBoxUI // limit button width to height of a raw combobox (without insets) FontMetrics fm = comboBox.getFontMetrics( comboBox.getFont() ); int maxButtonWidth = fm.getHeight() + scale( padding.top ) + scale( padding.bottom ); + int minButtonWidth = (maxButtonWidth * 3) / 4; + // make button square (except if width is limited) Insets insets = getInsets(); - int buttonWidth = Math.min( parent.getPreferredSize().height - insets.top - insets.bottom, maxButtonWidth ); + int buttonWidth = Math.min( Math.max( parent.getHeight() - insets.top - insets.bottom, minButtonWidth ), maxButtonWidth ); + if( buttonWidth != arrowButton.getWidth() ) { - // set width of arrow button to preferred height of combobox + // set width of arrow button int xOffset = comboBox.getComponentOrientation().isLeftToRight() ? arrowButton.getWidth() - buttonWidth : 0; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java index d2b44fa9..1b26b3b0 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java @@ -483,9 +483,10 @@ public class FlatSpinnerUI // limit buttons width to height of a raw spinner (without insets) FontMetrics fm = spinner.getFontMetrics( spinner.getFont() ); int maxButtonWidth = fm.getHeight() + scale( padding.top ) + scale( padding.bottom ); + int minButtonWidth = (maxButtonWidth * 3) / 4; - // make button area square (if spinner has preferred height) - int buttonsWidth = Math.min( parent.getPreferredSize().height - insets.top - insets.bottom, maxButtonWidth ); + // make button area square (except if width is limited) + int buttonsWidth = Math.min( Math.max( buttonsRect.height, minButtonWidth ), maxButtonWidth ); buttonsRect.width = buttonsWidth; if( parent.getComponentOrientation().isLeftToRight() ) {