-3

So that nodes have internally different name but shows other name, that would be easy for me to apply searching constraints on original name, but display modified name.

 treePanel = new JUResourceTypeTreeStructurePanel
 (I18N_ID, "menu.title", _panelBinding,VIEW_NAME,     
    masterBindings,MASTER_VIEW_SYNC,
    wizard,archiveAction,toggleAction,unArchiveAction,   
    copyAction, pasteAction
 );

 JUCtrlHierTypeBinding[] masterBindings = new JUCtrlHierTypeBinding[]
 {
   new JUTreeAccessorTypeBinding("NodeType1", MASTER_VIEW_CLASS, "NameDate", "Children", masterIcon, masterIcon, masterIcon)
 };

so here in master binf=ding namedate is passed, get path returns path of namedate type which is then selected through binding, whether the searching is made through any id,name etc. i want this NAMEDATE to be NAMEDATEID, for unique search path creation but to show only name as nodename.

DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer()
  {
    public Component getTreeCellRendererComponent(JTree tree, Object value, Boolean selected, Boolean expanded, Boolean leaf, int row, Boolean hasFocus)
  {


    return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
  } 
  };

_SelectPanel.getJUTree().setCellRenderer(renderer);

what methos is there to change the node name, can anybody suggest.

Harshit Saklecha
  • 100
  • 1
  • 10
  • i have applied renderer and to binding i have passed a modified attribute name which i want to pass juresourcetypetreestructurepanel so that while searchin getpath() function returns treepath according to this node but iwant to show modified name in display of tree. – Harshit Saklecha Jan 09 '14 at 07:01
  • i need a general idea about how i should use render for this, can share code its confidential. – Harshit Saklecha Jan 09 '14 at 07:04
  • For better help sooner, post an [SSCCE](http://sscce.org/) (an SSCCE is not your private code, but simply an example that concentrates on the exact problem). Note the document is being reviewed and discussed on [this question](http://meta.stackexchange.com/q/214955/155831), contributions welcome. – Andrew Thompson Jan 09 '14 at 07:13
  • @hashit I'm often in similar situations where my company doesn't like to share some code. Can you give us an idea, even in pseudo code or stripped down code? – AncientSwordRage Jan 09 '14 at 07:13
  • yes wait as ppl are killing my reputation here. – Harshit Saklecha Jan 09 '14 at 07:14
  • please reply if you need more detail for my problem – Harshit Saklecha Jan 09 '14 at 07:18
  • See this Q&A about [proprietary](http://meta.stackexchange.com/q/140847/163188) code. – trashgod Jan 09 '14 at 09:52
  • Review complete. For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve). Note that the code snippets so far posted are neither an SSCCE *nor* an MCVE. – Andrew Thompson Jan 09 '14 at 18:01

1 Answers1

1

As shown in this complete example, DefaultMutableTreeNode "may also hold a reference to a user object." Your userObject can return the display name in toString(), while providing an accessor for the search name.

Addendum: I need only the name to be shown there, not the date.

The getTreeCellRendererComponent() method of DefaultTreeCellRenderer invokes "convertValueToText(), which ultimately invokes toString() on value." Your implementation should instead call setText() with your preferred value, perhaps derived from the value established by the super implementation.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • but "namedate" is the complete node name of the tree, i need only name to be shown there not the date, while searching based on name date, no function there in renderer to override the name of node. – Harshit Saklecha Jan 10 '14 at 05:23