Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how will I display the new node added to the mother node in a JTree object...?
My code displays the first child node created but not the second or the third and so on how will I display the other child nodes created...? Please help...

What I have tried:

String strRep=null;
       strRep=getID(); // this function returns null or a string value
       protected static DefaultTreeModel treeModel;// declared in class level
       boolean shouldBeVisible=true;
       if(strRep!=null) 
       {
        
	       String path=System.getProperty("user.dir");
        // getRepositoryName returns a string     
	    
		File Cr=new File(path + "/" + getRepositoryName() );
        	b=Cr.mkdir();
		DefaultMutableTreeNode nrep=new DefaultMutableTreeNode(getRepositoryName());
		 
	         if(b)
            	{
               		toolkit.beep();
		            treeModel.insertNodeInto(nrep, rep, rep.getChildCount());
		         }
       }
if(shouldBeVisible)
        {
            tree.scrollPathToVisible(new TreePath(nrep.getPath()));
        }
Posted
Updated 23-Jun-22 3:53am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900