Open wyj3531 opened 1 year ago
The "folder" and "leaf" icons are coming from the usual cell renderer and can be modified by providing a custom cell renderer into the tree the same way you do it with any other normal tree.
The check icon is hidden in the cell renderer that wraps provided one to add WebTristateCheckBox
to it - the check icon is the WebTristateCheckBox
icon. You can change it via style for checkboxtree
(it contains child style for the tristate checkbox in which you can change the icon) or by providing a custom CheckBoxTreeCellRenderer
via setCheckBoxTreeCellRenderer(...)
method in WebCheckBoxTree
, for instance a customized version of WebCheckBoxTreeCellRenderer
, although I would definitely recommend modifying it via style since it's generally less painful and "dirty" approach.
when i use WebTristateCheckBox checkBox =tree.getCheckBoxCellRenderer().getCheckBox(); and set icon ,state change icon don not change ,why ?
WebTristateCheckBox checkBox =tree.getCheckBoxCellRenderer().getCheckBox(); checkBox.setIcon(icon); checkBox.setSelectedIcon(selectIcon); checkBox.setPressedIcon(selectIcon);
and also i set the code ,it also no correct tree.getUI().setExpandedIcon(DemoIcons.twitter16); tree.getUI().setCollapsedIcon(DemoIcons.facebook16);
when i use WebTristateCheckBox checkBox =tree.getCheckBoxCellRenderer().getCheckBox(); and set icon ,state change icon don not change ,why ?
WebTristateCheckBox checkBox =tree.getCheckBoxCellRenderer().getCheckBox(); checkBox.setIcon(icon); checkBox.setSelectedIcon(selectIcon); checkBox.setPressedIcon(selectIcon);
WebLaF tristate checkbox doesn't use those icons to paint its states - instead it uses a custom icon installed by the AbstractStateButtonPainter
to paint states based on the tristatecheckbox
style:
https://github.com/mgarin/weblaf/blob/master/modules/ui/src/com/alee/skin/light/resources/tristatecheckbox.xml#L25
Unfortunately I don't have a good/quick solution for this except for suggesting to use custom style for the tree/tristatecheckbox instead of custom icons. Checkboxes were implemented in this way in advance to avoid limitations of multiple icons usage for when state animations will be implemented for the component styles.
and also i set the code ,it also no correct tree.getUI().setExpandedIcon(DemoIcons.twitter16); tree.getUI().setCollapsedIcon(DemoIcons.facebook16);
This is a good catch, it is indeed a bug - the +/- icons are basically hardcoded in WebTreeUI
to return specific predefined icons. I've added a separate issue to fix this in future updates: #703
there has some problem, how to change this icon? in WebCheckBoxTree