Home how to print the child node by loop in jtree
Reply: 0

how to print the child node by loop in jtree

user1593
1#
user1593 Published in August 15, 2018, 5:38 am

i want to to print the child node by loop, i have written the following code to do it without loop.

but to get manually to print the all the child node, i have written the following code.

 System.out.println("first child  : "+ selectednode.getFirstChild());
                  System.out.println("second child : "+ selectednode.getChildAfter(selectednode.getFirstChild()));
                  System.out.println("third child"+ selectednode.getChildAfter(selectednode.getChildAfter(selectednode.getFirstChild())));

and i written following to do it by loop

    int abcd = selectednode.getChildCount();
                  System.out.println(" u"+ abcd);
                 
                  
                  while(selectednode.getChildCount() == abcd)
                  {
                      System.out.println("child : "+ selectednode.getFirstChild());
                      selectednode.getChildAfter(selectednode.getFirstChild());
                  
                  }

how can i increment the in the above code that it print the next then next untill all child nodes are printed.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.292022 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO