Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display contents in GUI format

 
Avinash Rakkasagi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a Java code which displays the contents of a XML file in text format when used in NetBeans IDE. Can someone please modify the code so that I can display the result in GUI format with compress and expand features i.e I want the result in tree structure with compress and expand features added to the tree.

 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avinash Rakkasagi wrote:
Urgent help required!!!

http://www.coderanch.com/how-to/java/EaseUp

http://www.coderanch.com/how-to/java/UseCodeTags
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use a JTree for this purpose. And you also need to write your TreeModel to hold the data. Expansion and Collapse stuff is automatically provided by the JTree component.
I suggest you go throught the tutorial which is a great place to start.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avinash Rakkasagi wrote:Can someone please modify the code so that I can display the result in GUI format with compress and expand features


Well champ, you have to TellTheDetails. For instance, what is the structure of your XML file? Where/how do you want it do be displayed?

Anyway, we'll do even better: you will tell you how you could structure your code so you can achieve your goal!

First, what you can do is define an interface that will abstract the reading of your XML file. You have nodes that represent a data structure that keeps information about particular objects in your XML, right? Let's say that your XML file keeps information about people, so let's say that the node is Person. In the constructor of the implementation of this interface, you can read the XML file, given its path. Then, you can consume the methods offered by this interface in your window. You can instantiate the objects in the main method of your application.



Please take a look at it and let us know if you have doubts!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic