java - How to update tree node size with custom model? -
i using custom model in jtree
. when label of node changes, passing treemodelevent
listeners in following way:
protected void firenodechanged(treepath path) { treemodelevent evt = new treemodelevent(this, path); for(treemodellistener listener : listeners) { listener.treenodeschanged(evt); } }
where path
path changed node, including itself.
this causes title change, size of not:
swing truncates title , adds ellipsis (pointed red arrow).
how fix this? note have custom model , can't call nodechanged
, should emulate it.
without snippet there several guesses make, situation seems familiar me. try adding renderer jtree
performs updateui()
on rendering component before returning it:
tree.setcellrenderer(new defaulttreerenderer() { public component gettreecellrenderercomponent(jtree tree, object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasfocus) { component c = super.gettreecellrenderercomponent(tree, value, selected, expanded, leaf, row, hasfocus); // can more changes here ((jcomponent) c).updateui(); return c; }});
about updating, if "emulating" means implementing , what's supposed do, that's correct. long implements treemodel
, methods what's supposed, jtree
should rest.
the truncation might related fact trees , tables not lay "components" out use renderers instead paint them in faked containers.
and, way, can have @ eventlistenerlist
proper collection of event listeners.
Comments
Post a Comment