JTree Update

When me interface class is ran, the JTree is initially empty. When I click on a JButton, lets say its called 慡tart? a method is invoked that returns a String array from an external class back to a String array in my interface class. This String array is then used to create the objects in my JTree.

I know my JTree works fines. I抳e tested it by initialising the String array in the interface class with dummy data. I also know that my method for returning the array from the other class works ok, because I can print the values to the console. Still, I can抰 get my JTree to update itself. I抳e tried a few things that I抳e found in the forum, but nothing has worked so far.

Perhaps we could start with someone outlining or pointing me towards an example?

Any ideas would be appreciated.

[809 byte] By [firellia] at [2007-10-3 3:04:59]
# 1
After you load the tree you need to call: treeModel.nodeStructureChanged(rootNode).
BinaryDigita at 2007-7-14 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 2
Also if u want your jtree to be dynamic, try converting your jtree class into a Thread with that bit of code above
acer_troublea at 2007-7-14 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 3

> I抳e tried a few things that I抳e found in the forum

Well, Swing related questions should be posted in the Swing forum. You will probably find better examples there.

In general you udate the model of the tree and it will repaint the tree automatically.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.

camickra at 2007-7-14 20:55:03 > top of Java-index,Java Essentials,Java Programming...