mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Tree: Fixed missing custom closed/opened/leaf icons of a custom DefaultTreeCellRenderer. (issue #653; regression since implementing PR #609 in FlatLaf 3.0)
This commit is contained in:
@@ -38,6 +38,9 @@ FlatLaf Change Log
|
||||
- Updated "Hiberbee Dark" and "Material Theme UI Lite" themes.
|
||||
- Styling: Fixed resolving of UI variables in styles that use other variables.
|
||||
- MenuItem: Fixed horizontal alignment of icons. (issue #631)
|
||||
- Tree: Fixed missing custom closed/opened/leaf icons of a custom
|
||||
`DefaultTreeCellRenderer`. (issue #653; regression since implementing PR #609
|
||||
in FlatLaf 3.0)
|
||||
- Tree: Fixed truncated node text and too small painted non-wide node background
|
||||
if custom cell renderer sets icon, but not disabled icon, and tree is
|
||||
disabled. (issue #640)
|
||||
|
||||
@@ -158,6 +158,10 @@ public class FlatTreeUI
|
||||
// only used via styling (not in UI defaults, but has likewise client properties)
|
||||
/** @since 2 */ @Styleable protected boolean paintSelection = true;
|
||||
|
||||
private Icon defaultLeafIcon;
|
||||
private Icon defaultClosedIcon;
|
||||
private Icon defaultOpenIcon;
|
||||
|
||||
private boolean paintLines;
|
||||
private Color defaultCellNonSelectionBackground;
|
||||
private Color defaultSelectionBackground;
|
||||
@@ -193,6 +197,10 @@ public class FlatTreeUI
|
||||
showCellFocusIndicator = UIManager.getBoolean( "Tree.showCellFocusIndicator" );
|
||||
showDefaultIcons = UIManager.getBoolean( "Tree.showDefaultIcons" );
|
||||
|
||||
defaultLeafIcon = UIManager.getIcon( "Tree.leafIcon" );
|
||||
defaultClosedIcon = UIManager.getIcon( "Tree.closedIcon" );
|
||||
defaultOpenIcon = UIManager.getIcon( "Tree.openIcon" );
|
||||
|
||||
paintLines = UIManager.getBoolean( "Tree.paintLines" );
|
||||
defaultCellNonSelectionBackground = UIManager.getColor( "Tree.textBackground" );
|
||||
defaultSelectionBackground = selectionBackground;
|
||||
@@ -219,6 +227,10 @@ public class FlatTreeUI
|
||||
selectionInactiveForeground = null;
|
||||
selectionBorderColor = null;
|
||||
|
||||
defaultLeafIcon = null;
|
||||
defaultClosedIcon = null;
|
||||
defaultOpenIcon = null;
|
||||
|
||||
defaultCellNonSelectionBackground = null;
|
||||
defaultSelectionBackground = null;
|
||||
defaultSelectionForeground = null;
|
||||
@@ -233,11 +245,16 @@ public class FlatTreeUI
|
||||
// remove default leaf/closed/opened icons
|
||||
if( !showDefaultIcons && currentCellRenderer instanceof DefaultTreeCellRenderer ) {
|
||||
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) currentCellRenderer;
|
||||
if( renderer.getLeafIcon() == defaultLeafIcon &&
|
||||
renderer.getClosedIcon() == defaultClosedIcon &&
|
||||
renderer.getOpenIcon() == defaultOpenIcon )
|
||||
{
|
||||
renderer.setLeafIcon( null );
|
||||
renderer.setClosedIcon( null );
|
||||
renderer.setOpenIcon( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MouseListener createMouseListener() {
|
||||
|
||||
@@ -439,6 +439,11 @@ public class FlatComponents2Test
|
||||
tree.setCellRenderer( new TestDefaultTreeCellRenderer() );
|
||||
break;
|
||||
|
||||
case "defaultWithIcons":
|
||||
for( JTree tree : trees )
|
||||
tree.setCellRenderer( new TestDefaultWithIconsTreeCellRenderer() );
|
||||
break;
|
||||
|
||||
case "defaultWithIcon":
|
||||
for( JTree tree : trees )
|
||||
tree.setCellRenderer( new TestDefaultWithIconTreeCellRenderer() );
|
||||
@@ -960,6 +965,7 @@ public class FlatComponents2Test
|
||||
treeRendererComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||
"default",
|
||||
"defaultSubclass",
|
||||
"defaultWithIcons",
|
||||
"defaultWithIcon",
|
||||
"label",
|
||||
"swingxDefault",
|
||||
@@ -1612,6 +1618,18 @@ public class FlatComponents2Test
|
||||
}
|
||||
}
|
||||
|
||||
//---- class TestDefaultWithIconsTreeCellRenderer -------------------------
|
||||
|
||||
private static class TestDefaultWithIconsTreeCellRenderer
|
||||
extends TestDefaultTreeCellRenderer
|
||||
{
|
||||
public TestDefaultWithIconsTreeCellRenderer() {
|
||||
setLeafIcon( UIManager.getIcon( "FileView.floppyDriveIcon" ) );
|
||||
setClosedIcon( UIManager.getIcon( "FileView.hardDriveIcon" ) );
|
||||
setOpenIcon( UIManager.getIcon( "FileView.computerIcon" ) );
|
||||
}
|
||||
}
|
||||
|
||||
//---- class TestDefaultWithIconTreeCellRenderer --------------------------
|
||||
|
||||
private static class TestDefaultWithIconTreeCellRenderer
|
||||
|
||||
@@ -411,6 +411,7 @@ new FormModel {
|
||||
selectedItem: "default"
|
||||
addElement( "default" )
|
||||
addElement( "defaultSubclass" )
|
||||
addElement( "defaultWithIcons" )
|
||||
addElement( "defaultWithIcon" )
|
||||
addElement( "label" )
|
||||
addElement( "swingxDefault" )
|
||||
|
||||
Reference in New Issue
Block a user