• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display contents in GUI format

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Avinash Rakkasagi wrote:
Urgent help required!!!


https://coderanch.com/how-to/java/EaseUp

https://coderanch.com/how-to/java/UseCodeTags
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic