diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java index c1fa40bce..01a9896f1 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java @@ -28,6 +28,7 @@ import java.awt.event.FocusListener; import java.beans.PropertyChangeListener; import java.util.Map; +import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListCellRenderer; import javax.swing.JComponent; import javax.swing.JList; @@ -308,16 +309,7 @@ protected void paintCell( Graphics g, int row, Rectangle rowBounds, ListCellRend Component rendererComponent = cellRenderer.getListCellRendererComponent( list, dataModel.getElementAt( row ), row, isSelected, FlatUIUtils.isPermanentFocusOwner( list ) && (row == leadIndex) ); - - if( alternateRowColor != null && row % 2 != 0 ) { - g.setColor( alternateRowColor ); - - // paint respecting selection arc - final float arc = UIScale.scale( selectionArc / 2f ); - FlatUIUtils.paintSelection( (Graphics2D) g, 0, rowBounds.y, list.getWidth(), rowBounds.height, - UIScale.scale( selectionInsets ), arc, arc, arc, arc, 0 ); - } - + // boolean isFileList = Boolean.TRUE.equals( list.getClientProperty( "List.isFileList" ) ); int cx, cw; @@ -331,6 +323,18 @@ protected void paintCell( Graphics g, int row, Rectangle rowBounds, ListCellRend cx = rowBounds.x; cw = rowBounds.width; } + + // filelist/combobox does not support alternate row color + if( !isFileList && !(dataModel instanceof DefaultComboBoxModel) ) { + if( alternateRowColor != null && row % 2 != 0 ) { + g.setColor( alternateRowColor ); + + // paint respecting selection arc + final float arc = UIScale.scale( selectionArc / 2f ); + FlatUIUtils.paintSelection( (Graphics2D) g, 0, rowBounds.y, list.getWidth(), rowBounds.height, + UIScale.scale( selectionInsets ), arc, arc, arc, arc, 0 ); + } + } // rounded selection or selection insets if( isSelected &&