Hi. I'm somewhat new to
Java and Swing. I'm working on a relatively simple demo application that builds and saves a JTree to file. Everything works great, but I have a question about the best way to redraw the JTree.
My screen is structurued as follows:
JTree inside a JScrollPane inside a JSplitPane inside a JFrame.
When I open my saved file, I re-create the JTree based on the data from the file, and I need to re-paint the JTree, etc. In looking at other posts here, it is suggested that I use the revalidate() command and repaint() command. I've tried various combinations without success.
The only way I've gotten this to work is as follows:
frame.remove(splitPane);
makeSplitPane(); // re-build the entire splitpane
frame.setContentPane(splitPane);
frame.setVisible(true);
This works fine, but it doesn't seem like the best way to do this. I'm probably missing something simple. Any suggestions will be appreciated. Thanks. Mark Dexter