0
I intend to display a tree in Java GUI. 

The nodes of the tree will depict the function names of the program which the user will enter during runtime and the edges of the tree will depict a function call. So if main calls func1, there will be 2 nodes in the tree (main and func1) and an edge from main to func1. It will differ according to the program which the user entered. This tree may not be a binary tree since a single function may call more than two functions and may be recursive.

I studied JTree and I felt I wont be getting the desired output in the desired design using it.

I even consider tools such as Prefuse but that will increase the size of my application. Is there any other way of displaying the above?

Desired Output - If the program is

void main()   //program begins here
{
   func1();
   func2();
}

void func1()
{
      x=0;
     if(x<5)
     {
        func1();
        x++;
     }
}

void func2()
{
      sum();
      diff();
      mul();
}

void sum()
{
      printf("2+5=7");
}
void diff()
{
      printf("2-5=-3");
}
void mul()
{
     printf("2*5=10");
}

Its output should be-

               main
              /   \
             /     \
      ----->func1  func2
      |-------|    /  \  \
                  /    \  \ 
                 sum   diff mul

I was not able to display the image. Its in http://postimg.org/image/5uovbguz9/

userP
  • 1
  • 2
  • *"Could someone please direct me."* Form a question and add it as an [edit to the question](http://stackoverflow.com/posts/16059275/edit). – Andrew Thompson Apr 17 '13 at 11:56
  • We don't know your "desired design", your imaginations. Could you please provide some detail so one could come up with something that fits your needs? – Powerslave Apr 17 '13 at 11:58
  • @Powerslave I have edited the question to show the expected output. Since I does not have 10 reputation I was not able to upload the image. I have tried my best so that everyone can understand.Also I have attached the link to the image. Please check this out. I have been trying this since 4 days. – userP Apr 17 '13 at 14:47
  • 2
    not supported in core swing, you might want to look into some 3rd party framework, f.i. JUNG – kleopatra Apr 17 '13 at 15:32
  • 1
    Or one of [these](http://stackoverflow.com/a/15702152/230513). – trashgod Apr 17 '13 at 17:59

0 Answers0