java - Binding HashMap<String, String> to MutableTreeNode -


i need bind hashmap mutabletreenode can display in jtree.

i have following code:

static map<string, string> form = new linkedhashmap<string,string>(); 

i guess how need implement mutabletreenode. don't know how procees key's of "form" show in mutabletreenode.

public class mynode implements mutabletreenode {      @override     public enumeration children() {         // todo auto-generated method stub         return null;     }      @override     public boolean getallowschildren() {         // todo auto-generated method stub         return false;     }      @override     public treenode getchildat(int childindex) {         // todo auto-generated method stub         return null;     }      @override     public int getchildcount() {         // todo auto-generated method stub         return 0;     }      @override     public int getindex(treenode node) {         // todo auto-generated method stub         return 0;     }      @override     public treenode getparent() {         // todo auto-generated method stub         return null;     }      @override     public boolean isleaf() {         // todo auto-generated method stub         return false;     }      @override     public void insert(mutabletreenode arg0, int arg1) {         // todo auto-generated method stub      }      @override     public void remove(int arg0) {         // todo auto-generated method stub      }      @override     public void remove(mutabletreenode arg0) {         // todo auto-generated method stub      }      @override     public void removefromparent() {         // todo auto-generated method stub      }      @override     public void setparent(mutabletreenode arg0) {         // todo auto-generated method stub      }      @override     public void setuserobject(object arg0) {         // todo auto-generated method stub      } 

after mutabletreenode correctly shows correct key value, want able do:

final jtree tree = new jtree(); final defaultmutabletreenode customnode = new defaultmutabletreenode("custom"); defaulttreemodel tm = new defaulttreemodel(customnode); tree.setmodel(tm);  (string str : form.keyset())         {           mynode nod = new mynode(str);           customnode.add(node);                    } tm.reload(); 

you want custom implementation of treemodel interface. noted in how use trees: creating data model,

the treemodel interface accepts kind of object tree node. not require nodes represented defaultmutabletreenode objects, or nodes implement treenode interface.

although map<string, string> not intrinsically hierarchical, may idea genealogymodel, cited here, or filetreemodel cited here , here.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -