• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using JTree to load a file

 
Kevin Magee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I've been messing around with the JTabletree example from the Sun Swing tutorial. I've been trying to include it in a basic text editor which I've been using to practice using swing...however I can't seem to get the Jtabletree to launch a file
I've got it to list a series of summaries of files in a specificied directory (title, URL/path, first accessed, last accessed) and want to allow the user to click on the Jtabletree and launch the file into my text editor panel. Basically, I just need to get the URL from a column in the selected row which I can then pass to the text editors loader.
Any suggestions?
I'll give code if its this query is a bit vague. I know that its a lot to ask for advice on what is a custom Jtree model, but for the life of me I can't figure it how and it should be quite easy.
Any help would be greatly appreciated.
Regards,
Kevin.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would add a mouselistener to the JTree that looks something like this... I tend to go with a MouseListener rather than a TreeSelectionListener because you can have the user double-click to launch the document, which most users are more used to...

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!