• Post Reply Bookmark Topic Watch Topic
  • New Topic

Small JTree node question  RSS feed

 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quick question! Bit of a noob here :P

When you select a node in a JTree can you then populate a JPanel based on more information about that node from a file?
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the section from the Swing tutorial on How to Use Trees for a working example.
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have and I know it will be possible to code but everything in those articles are just hardcoded - I don't want anything hardcoded.

I want it from a file - which I can't find anything relevant enough on how to do or anyone who could help :/

Thanks for replying though!
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean hardcoded? The "BookInfo" information is read in from an HTML file. Yes the "BookTile" and "BookURL" are hardcoded in the program, but that would be easy to read in from a file.

So yes the example may require a little change, but nothing major. All you need to do is modify the "CreateNodes" method from the demo code. You would change the code to read the data in from a file, so you would need a loop to read a line of data from the file and parse out the title and URL and then build the node.
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah actually that makes sense - so thanks for pointing it out like that.

The thing thats stopping me is really the properties file im using as prop files tend to use key pair values

I already have my key displaying just fine, I just need the value that goes with it - I understand it will probably be ___.getProperty();

I'm just a tad lost on how to use/reference the prop file - I thought maybe the words 'key' and 'value' could be used but how is the program supposed to know what a key and what a value is out of that file :S
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!