• 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

Using TreeModel: How to implement editing!!??

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am implementing TreeModel to buil a custom model to a JTree.
My problem is when a Edit the Model (add,remove,change value of a Node ) my Tree does no refresh to present the accurate data. I have seen lots of example on the web, but each time people are using DefaultMutableTree .. to perform editing operation. I am writing an xml Editor that uses a DOM parser to read the data into a DOM that I display using a JTree. Then I sue a SAX 2 parser to validate the data against a schema and display errors in a different rendering. Now I need to enable the user to edit the xml DOM Tree in order to correct the file.
Itried implementing a TreeModelListener class, but I have no idea of what kind of code should go into each method of the interface to get my tree updated.
I really need help quicklly and would be greatefull of example with code samples:I read a lot about the theory but still not getting there
Thanks.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Swing.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use any of the methods in DefaultTreeModel that work best for you:
nodeChanged(TreeNode node)
nodesChanged(TreeNode node, int[] childIndices)
nodeStructureChanged(TreeNode node)
nodesWereInserted(TreeNode node, int[] childIndices)
nodesWereRemoved(TreeNode node, int[] childIndices, Object[] removedChildren)
fireTreeNodesChanged(Object source, Object[] path,
int[] childIndices, Object[] children)
fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children)
fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children)
fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children)
Bill
reply
    Bookmark Topic Watch Topic
  • New Topic