DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004

    Java Swing JTree update content

    Hello all,

    I've got the following problem:
    I have a Jtree, which is in the left side of my JSplitPane. When I select an item in the tree, I get the option to edit it in the Right part of the SplitPane. Everything works fine so far. Once I editted the item, I pres the save button, which puts my updated item into the database (works fine) and updates the tree to represent the new item. This last part is where the problems begin. The text of the item is not updated. Once I select a different item in the tree the text of the changed Item changes, but I can't figure out how to change it while the text is selected.

    Any help would be appreciated.


  2. #2
    Join Date
    Mar 2004
    Try looking at this method.

    protected void fireValueChanged(TreeSelectionEvent e)

    What's happening is that the tree isn't being redrawn until you've selected a new item.

  3. #3
    Join Date
    Oct 2004
    great, will do.
    now to find a way to call it from outside the tree....

    I've already tried setting the selection to a different item, calling repaint() and resetting the selection with no effect

  4. #4
    Join Date
    Aug 2003
    What people usually do for things like this is subclass the TreeModel with their own model. Then you expose the model and give it methods like changeData() or something that do exactly what you want them to do and then call the fire... events. You will want to subclass the DefaultTreeModel so that you dont' have to write all of the stuff, but make sure that you override some of the methods if you need to.

    Hope this helps.

  5. #5
    Join Date
    Oct 2004
    I was hoping to avoid having to do this. But it looks like I have no choice. Oh well...

    Btw. The program I'm currently working on is becoming bigger and bigger, so I could really use some help, if people are interested, send me a PM. The program is (currently) a character generator for the DnD pen and paper Roleplaying Game. But the goal is to make it compatible with all D20 RPGs, and add conline gaming functionality as well.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.