mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 06:20:53 +03:00
new: support for alternate row color in jtree
see: https://github.com/JFormDesigner/FlatLaf/issues/900
This commit is contained in:
@@ -102,6 +102,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
* @uiDefault Tree.selectionForeground Color
|
* @uiDefault Tree.selectionForeground Color
|
||||||
* @uiDefault Tree.selectionInactiveBackground Color
|
* @uiDefault Tree.selectionInactiveBackground Color
|
||||||
* @uiDefault Tree.selectionInactiveForeground Color
|
* @uiDefault Tree.selectionInactiveForeground Color
|
||||||
|
* @uiDefault Tree.alternateRowColor Color
|
||||||
* @uiDefault Tree.selectionInsets Insets
|
* @uiDefault Tree.selectionInsets Insets
|
||||||
* @uiDefault Tree.selectionArc int
|
* @uiDefault Tree.selectionArc int
|
||||||
* @uiDefault Tree.wideSelection boolean
|
* @uiDefault Tree.wideSelection boolean
|
||||||
@@ -141,6 +142,7 @@ public class FlatTreeUI
|
|||||||
@Styleable protected Color selectionInactiveBackground;
|
@Styleable protected Color selectionInactiveBackground;
|
||||||
@Styleable protected Color selectionInactiveForeground;
|
@Styleable protected Color selectionInactiveForeground;
|
||||||
@Styleable protected Color selectionBorderColor;
|
@Styleable protected Color selectionBorderColor;
|
||||||
|
@Styleable protected Color alternateRowColor;
|
||||||
/** @since 3 */ @Styleable protected Insets selectionInsets;
|
/** @since 3 */ @Styleable protected Insets selectionInsets;
|
||||||
/** @since 3 */ @Styleable protected int selectionArc;
|
/** @since 3 */ @Styleable protected int selectionArc;
|
||||||
@Styleable protected boolean wideSelection;
|
@Styleable protected boolean wideSelection;
|
||||||
@@ -192,6 +194,7 @@ public class FlatTreeUI
|
|||||||
selectionInactiveBackground = UIManager.getColor( "Tree.selectionInactiveBackground" );
|
selectionInactiveBackground = UIManager.getColor( "Tree.selectionInactiveBackground" );
|
||||||
selectionInactiveForeground = UIManager.getColor( "Tree.selectionInactiveForeground" );
|
selectionInactiveForeground = UIManager.getColor( "Tree.selectionInactiveForeground" );
|
||||||
selectionBorderColor = UIManager.getColor( "Tree.selectionBorderColor" );
|
selectionBorderColor = UIManager.getColor( "Tree.selectionBorderColor" );
|
||||||
|
alternateRowColor = UIManager.getColor( "Tree.alternateRowColor" );
|
||||||
selectionInsets = UIManager.getInsets( "Tree.selectionInsets" );
|
selectionInsets = UIManager.getInsets( "Tree.selectionInsets" );
|
||||||
selectionArc = UIManager.getInt( "Tree.selectionArc" );
|
selectionArc = UIManager.getInt( "Tree.selectionArc" );
|
||||||
wideSelection = UIManager.getBoolean( "Tree.wideSelection" );
|
wideSelection = UIManager.getBoolean( "Tree.wideSelection" );
|
||||||
@@ -227,6 +230,7 @@ public class FlatTreeUI
|
|||||||
selectionInactiveBackground = null;
|
selectionInactiveBackground = null;
|
||||||
selectionInactiveForeground = null;
|
selectionInactiveForeground = null;
|
||||||
selectionBorderColor = null;
|
selectionBorderColor = null;
|
||||||
|
alternateRowColor = null;
|
||||||
|
|
||||||
defaultLeafIcon = null;
|
defaultLeafIcon = null;
|
||||||
defaultClosedIcon = null;
|
defaultClosedIcon = null;
|
||||||
@@ -570,6 +574,11 @@ public class FlatTreeUI
|
|||||||
boolean isSelected = tree.isRowSelected( row );
|
boolean isSelected = tree.isRowSelected( row );
|
||||||
boolean isDropRow = isDropRow( row );
|
boolean isDropRow = isDropRow( row );
|
||||||
boolean needsSelectionPainting = (isSelected || isDropRow) && isPaintSelection();
|
boolean needsSelectionPainting = (isSelected || isDropRow) && isPaintSelection();
|
||||||
|
|
||||||
|
if( alternateRowColor != null && row % 2 != 0 ) {
|
||||||
|
g.setColor( alternateRowColor );
|
||||||
|
FlatUIUtils.paintComponentBackground((Graphics2D) g, bounds.x, bounds.y, tree.getWidth(), bounds.height, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// do not paint row if editing
|
// do not paint row if editing
|
||||||
if( isEditing ) {
|
if( isEditing ) {
|
||||||
|
|||||||
@@ -965,6 +965,7 @@ public class TestFlatStyleableInfo
|
|||||||
"selectionInactiveBackground", Color.class,
|
"selectionInactiveBackground", Color.class,
|
||||||
"selectionInactiveForeground", Color.class,
|
"selectionInactiveForeground", Color.class,
|
||||||
"selectionBorderColor", Color.class,
|
"selectionBorderColor", Color.class,
|
||||||
|
"alternateRowColor", Color.class,
|
||||||
"selectionInsets", Insets.class,
|
"selectionInsets", Insets.class,
|
||||||
"selectionArc", int.class,
|
"selectionArc", int.class,
|
||||||
"wideSelection", boolean.class,
|
"wideSelection", boolean.class,
|
||||||
|
|||||||
@@ -1182,6 +1182,7 @@ Tree.dropCellForeground
|
|||||||
Tree.dropLineColor
|
Tree.dropLineColor
|
||||||
Tree.editorBorder
|
Tree.editorBorder
|
||||||
Tree.editorBorderSelectionColor
|
Tree.editorBorderSelectionColor
|
||||||
|
Tree.alternateRowColor
|
||||||
Tree.expandedIcon
|
Tree.expandedIcon
|
||||||
Tree.focusInputMap
|
Tree.focusInputMap
|
||||||
Tree.focusInputMap.RightToLeft
|
Tree.focusInputMap.RightToLeft
|
||||||
|
|||||||
Reference in New Issue
Block a user