diff --git a/CHANGELOG.md b/CHANGELOG.md index fb6df4bc..e6d47e37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ FlatLaf Change Log #### Fixed bugs +- ComboBox (not editable): Fixed background painted outside of border if round + edges are enabled (client property `JComponent.roundRect` is `true`). (similar + to issue #382; regression since fixing #330 in FlatLaf 1.4) - Tree: Fixed editing cell issue with custom cell renderer and cell editor that use same component for rendering and editing. (issue #385) @@ -41,7 +44,7 @@ FlatLaf Change Log - ComboBox (editable): Fixed wrong border of internal text field under special circumstances. - Spinner: Fixed painting of border corners on left side. (issue #382; - regression since FlatLaf 1.4) + regression since fixing #330 in FlatLaf 1.4) - TableHeader: Do not show resize cursor for last column if resizing last column is not possible because auto resize mode of table is not off. (issue #332) - TableHeader: Fixed missing trailing vertical separator line if used in upper 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 6982a601..ad1fbab1 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 @@ -555,6 +555,22 @@ public class FlatComboBoxUI @Override @SuppressWarnings( "unchecked" ) public void paintCurrentValue( Graphics g, Rectangle bounds, boolean hasFocus ) { + // apply clipping using rounded rectangle to avoid that renderer paints + // outside of border if combobox uses larger arc for edges + // (e.g. FlatClientProperties.COMPONENT_ROUND_RECT is true) + FlatBorder border = FlatUIUtils.getOutsideFlatBorder( comboBox ); + if( border != null ) { + int clipArc = border.getArc( comboBox ) - (border.getLineWidth( comboBox ) * 2); + if( clipArc > 0 ) { + int x = bounds.x; + int width = bounds.width + bounds.height; + if( !comboBox.getComponentOrientation().isLeftToRight() ) + x -= bounds.height; + ((Graphics2D)g).clip( FlatUIUtils.createComponentRectangle( + x, bounds.y, width, bounds.height, scale( (float) clipArc ) ) ); + } + } + paddingBorder.uninstall(); ListCellRenderer renderer = comboBox.getRenderer();