Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when i use WebCheckBoxTree #702

Open
wyj3531 opened this issue Aug 9, 2022 · 4 comments
Open

when i use WebCheckBoxTree #702

wyj3531 opened this issue Aug 9, 2022 · 4 comments
Assignees
Labels
Projects

Comments

@wyj3531
Copy link

wyj3531 commented Aug 9, 2022

there has some problem, how to change this icon? in WebCheckBoxTree
image

@mgarin
Copy link
Owner

mgarin commented Aug 10, 2022

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.

@mgarin mgarin added this to Styling in Questions Aug 10, 2022
@wyj3531
Copy link
Author

wyj3531 commented Aug 11, 2022

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);

@wyj3531
Copy link
Author

wyj3531 commented Aug 11, 2022

and also i set the code ,it also no correct
tree.getUI().setExpandedIcon(DemoIcons.twitter16);
tree.getUI().setCollapsedIcon(DemoIcons.facebook16);
image

@mgarin
Copy link
Owner

mgarin commented Aug 12, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Questions
Styling
Development

No branches or pull requests

2 participants