This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Changes which we made in JTree are not reflecting in our file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changes which we made in JTree are not reflecting in our file" Watch "Changes which we made in JTree are not reflecting in our file" New topic
Author

Changes which we made in JTree are not reflecting in our file

rohit singh Patel
Greenhorn

Joined: Feb 05, 2012
Posts: 4

Hi Friends,
I'm a newbie in Java and we are creating one application where we fetch the data from the file and created the tree structure (JTree) and we are able to change the data in JTree but the changes which we made in JTree are not reflecting in our file. Please help me out with this how to push back the data to the same file with changes we made in JTree.
Thanks
Rohit Singh
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
you've obviously been reading about bold, how about you read up on listeners
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

Hi Rohit,
Welcome to the Ranch!

Please read about How To Ask Questions. And also remember to Keep It Down.
Please go through the links to understand how to pose questions.

Also, though your question is related to trees, the issue that this thread topic deals with is different. Asking a different question in someone's else thread is not considered polite and is known as thread hijacking. Please start a new topic with your question to get answers.

Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Rohit, please don't use bold tags or colouring in regular text. Also, if you keep the right case in class names, our forum software will often create an automatic link to the Javadoc page for that class. Compare JTREE (no link) versus JTree (link).
Also, Java is not an acronym so it shouldn't be written in all upper case letters.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

rohit, please continue this discussion here. I've locked the second thread you started with the same question.


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Darryl means this thread which includes a code snippet.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

You have used some logic to build the tree. Use the same logic to read the tree and write to the file. This 'save' operation can be done from a button or menuitem.

If you need to actively listen and write to the file then & there, you need to write a TreeModelListener to listen to instant changes. This tutorial can help you in that.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Changes which we made in JTree are not reflecting in our file
 
Similar Threads
How to save the changes made in Jtree to the source file
JTree
JTree
JTree
How to save a JTree content in a Text file and vise-versa