diff --git a/CHANGELOG.md b/CHANGELOG.md index ea9bc231..31d67472 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,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) - Table: Do not select text in cell editor when it gets focus (when `JTable.surrendersFocusOnKeystroke` is `true`) and `TextComponent.selectAllOnFocusPolicy` is `once` (the default) or `always`. @@ -43,7 +46,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 392efd52..759744b4 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 @@ -482,6 +482,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();