• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree and JFreechart in a single window  RSS feed

 
Ajay Singh
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all

My requirement is that i have to create an UI which contains two frames one on the left and one on the right.The left frame should display various nodes using JTree.Now when i click on one of the nodes of the tree,the right frame should display an xy plot using JFreechart based on the node selected.Separately i am able to make a Jtree having various nodes and a JFreechart of xy plot but together in a single window is it possible?Pointers to the same would be appreciated

Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's easily possible. You'd use a layout that can place components next to one another horizontally, like BoxLayout or GridLayout. Then you add two JPanels to that layout, which you can fill with whatever content you want (or add the JTree and JFreeChart components directly, without an intermediate JPanel).
 
Ajay Singh
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ulf for the reply

Now what i am doing is i have created file menu which contains "Open" and "Exit".Now if i click on the open button ,i will select an xml file and that xml file is to be loaded as a JTree.Without the file menu ,directly i am able to load an xml file in a JTree( in a separate program).What to put in the actionlistener part while clicking the "Open".Please help.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you're asking. Obviously, there needs to be code to get the filename (that'll involve a JFileChooser), and then you need to parse the XML (probably using a SAX parser through the JAXP API) and build up the JTree during parsing.
If you're unsure about any specific step, tell us what you have so far, and where you're stuck making progress. Note that XML questions should go into the XML forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!