swing - Renderer cell in JXTreeTable in base of content of a rows in java -


i'm using jxtreetable org.jdesktop.swingx display hierarchical structure data, i've parent nodes , child nodes attached them. want have different renderer parent , child nodes.

example: if jxtreetable shows parent node, first column should rendered string , others jcheckbox else if jxtreetable displays child node, every cell should rendered string.

first, write in mytreetablemodel extends abstracttreetablemodel piece of code:

@override public class<?> getcolumnclass(int column) {     if (column == 0)         return string.class;     return boolean.class; } 

everything ok in parent node, shows empty jcheckbox in child nodes have blank cell. returning null in method getvalueat(....) doesn't fix problem. so, thought use renderer class don't know start. write pseudo-renderer this:

private class customcellrender implements tablecellrenderer {    @override    public component gettablecellrenderercomponent(jtable table,         object value, boolean isselected, boolean hasfocus, int row,         int column) {    setopaque(true);    jcomponent component = null;     if (value instanceof parent_node) {         if (column == 0)             component = new jlabel();         else             component = new jcheckbox();     } else if (value instanceof child_node) {         component = new jlabel();     }     return component;    } } 

and set with:

mytreetable.setdefaultrenderer(object.class, new customcellrender()); 

could tell i'm wrong or give me tips solve problem? thank time.

edit: tried insert test system.out.println(...) in method gettablecellrenderercomponentbut it's never called. jtreetable never runs method.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -