Tree: hide default closed/opened/leaf icons by default

This commit is contained in:
Karl Tauber
2022-11-14 14:21:28 +01:00
parent 2be2dae3d6
commit b736502c27
11 changed files with 49 additions and 2 deletions

View File

@@ -105,6 +105,7 @@ import com.formdev.flatlaf.util.UIScale;
* @uiDefault Tree.selectionArc int
* @uiDefault Tree.wideSelection boolean
* @uiDefault Tree.showCellFocusIndicator boolean
* @uiDefault Tree.showDefaultIcons boolean
*
* <!-- FlatTreeExpandedIcon -->
*
@@ -143,6 +144,7 @@ public class FlatTreeUI
/** @since 3 */ @Styleable protected int selectionArc;
@Styleable protected boolean wideSelection;
@Styleable protected boolean showCellFocusIndicator;
/** @since 3 */ protected boolean showDefaultIcons;
// for icons
// (needs to be public because icon classes are in another package)
@@ -189,6 +191,7 @@ public class FlatTreeUI
selectionArc = UIManager.getInt( "Tree.selectionArc" );
wideSelection = UIManager.getBoolean( "Tree.wideSelection" );
showCellFocusIndicator = UIManager.getBoolean( "Tree.showCellFocusIndicator" );
showDefaultIcons = UIManager.getBoolean( "Tree.showDefaultIcons" );
paintLines = UIManager.getBoolean( "Tree.paintLines" );
defaultCellNonSelectionBackground = UIManager.getColor( "Tree.textBackground" );
@@ -223,6 +226,19 @@ public class FlatTreeUI
oldStyleValues = null;
}
@Override
protected void updateRenderer() {
super.updateRenderer();
// remove default leaf/closed/opened icons
if( !showDefaultIcons && currentCellRenderer instanceof DefaultTreeCellRenderer ) {
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) currentCellRenderer;
renderer.setLeafIcon( null );
renderer.setClosedIcon( null );
renderer.setOpenIcon( null );
}
}
@Override
protected MouseListener createMouseListener() {
return new BasicTreeUI.MouseHandler() {

View File

@@ -901,6 +901,7 @@ Tree.wideSelection = true
Tree.repaintWholeRow = true
Tree.paintLines = false
Tree.showCellFocusIndicator = false
Tree.showDefaultIcons = false
Tree.leftChildIndent = 7
Tree.rightChildIndent = 11
Tree.rowHeight = 0