Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace JTree handle icons

Tags:

java

swing

jtree

I'm trying to customize a JTree so that I can use it in a project that I'm working on. That project GUI's style does not fit the default Java LNF's node handles for JTree which is why I tried to replace them with custom-made icons but I'm stuck as to how I can do that. I don't know if that helps but I already have an own LNF class which loads the default LNF settings and overrides some of them with custom values.

Alternatively, if replacing the handles' icons is too complex to explain it in an answer here, how can I completely disable them so that I can use custom open/closed icons for all expandable nodes?

like image 352
mezzodrinker Avatar asked Nov 19 '25 18:11

mezzodrinker


1 Answers

By setting the UIManager properties Tree.collapsedIcon (for collapsed handles) and Tree.expandedIcon (for expanded handles) to the desired values, the handles for all JTrees can be changed at once. Thanks to @MadProgrammer for suggesting the examples shown here, here, here and here.

like image 160
3 revs, 2 users 50%trashgod Avatar answered Nov 22 '25 09:11

3 revs, 2 users 50%trashgod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!