mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06:00
Tree: fill cell background if DefaultTreeCellRenderer.setBackgroundNonSelectionColor(Color) was used (issue #322)
This commit is contained in:
@@ -1200,10 +1200,27 @@ public class FlatComponents2Test
|
||||
extends DefaultTreeCellRenderer
|
||||
{
|
||||
public TestDefaultTreeCellRenderer() {
|
||||
setBackgroundNonSelectionColor( Color.red );
|
||||
setBackgroundSelectionColor( Color.green );
|
||||
setTextSelectionColor( Color.blue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded,
|
||||
boolean leaf, int row, boolean hasFocus )
|
||||
{
|
||||
Color nonSelectionBg = null;
|
||||
Color nonSelectionFg = null;
|
||||
switch( String.valueOf( value ) ) {
|
||||
case "blue": nonSelectionFg = Color.blue; break;
|
||||
case "red": nonSelectionFg = Color.red; break;
|
||||
case "yellow": nonSelectionBg = Color.yellow; break;
|
||||
case "violet": nonSelectionBg = Color.magenta; break;
|
||||
}
|
||||
setBackgroundNonSelectionColor( nonSelectionBg );
|
||||
setTextNonSelectionColor( (nonSelectionFg != null) ? nonSelectionFg : UIManager.getColor( "Tree.textForeground" ) );
|
||||
|
||||
return super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus );
|
||||
}
|
||||
}
|
||||
|
||||
//---- class TestLabelTreeCellRenderer ------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user