CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2000
    Location
    Kaysville, UT
    Posts
    228

    How do I refresh a JTree?

    I'm having problems getting a JTree to reflect changes made to it's nodes. Basically, my tree contains a JPanel at each node. If I add or take away objects to those JPanels it is correctly done in software (an eneumeration of all the components in a given pane lists what it should contain). For some reason the added components do not appear in the JTree. I'm assuming this is just a problem with refreshing/updating the display. I've tried invalidate/validate and update, but nothing seems to work. Is there something I'm overlooking?

    Thanks!

    "There's nothing more dangerous than a resourceful idiot." ---Dilbert
    BWAHAHAHAHAHAHA! ---Murray

  2. #2
    Join Date
    Sep 2000
    Location
    Singapore
    Posts
    5

    Re: How do I refresh a JTree?

    U can refresh a JTree by invoking
    DefaultTreeModel.reload()

    If everything is right with panels then the validate method should definitely work

    Regards
    Praveen



    When going gets tough,
    Tough gets going.

  3. #3
    Join Date
    Nov 1999
    Location
    Indianapolis, IN
    Posts
    191

    Re: How do I refresh a JTree?

    Are you wanting to refresh the data? or the painting of your tree?

    I refreshed mine by setting the model to null. Then, my 'new' model is lazy initialized the next time the JTree requests data. this effectively refreshes both the data and the painting.

    I created a button, who's action sets the model to null...

    HOpe that helps,


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured