swing - TreeTableRender for JXTreeTable -
swing - TreeTableRender for JXTreeTable -
how can assign different renderers different column in jxtreetable. jxtreetable has different column types (like currency, date,...etc.). in jxtable used getcolumn(identifier).setcellrender(tablecellrender) method. should jxtreetable?
as long columns of same type handled equally, can assign default renderer class. instance, table has 2 columns java.util.date values , want them both handled in same way:
mytreetable.setdefaultrenderer(java.util.date.class, new defaulttablerenderer(stringvalues.date_to_string));
first argument type of object want renderer handle. sec argument cell renderer. swingx comes simple rendering mechanism called defaulttablerenderer. takes number of possible arguments, simplest 1 provide stringvalue instance. that's interface that, when implemented, takes arbitrary object , converts string in manner. stringvalues class contains few predefined implementations. in illustration above, utilize stringvalues.date_to_string, passes java.util.date object in cell default dateformat instance , returns string result. go on classes of object want handle.
if need specific rendering single column only, plug column middle of call:
mytreetable.getcolumnext(mycolumnidentifier).setcellrenderer(java.util.date.class, new defaulttablerenderer(mygloriousstringvalueconverter));
note phone call no longer setdefaultcellrenderer.
this rendering mechanism 1 of best features of swingx. easy utilize , quite potent in combination highlighter pipeline.
all applies table portion of jxtreetable. hierarchical column (first column) can setup in same way, phone call is
mytreetable.settreecellrenderer(new defaulttreerenderer(mygloriousstringvalue));
swing swingx tablecellrenderer jxtreetable jtreetable
Comments
Post a Comment