List of usage examples for javax.swing.tree TreeModel valueForPathChanged
public void valueForPathChanged(TreePath path, Object newValue);
path
to newValue
. From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Swing Package Hierarchy"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector rootVector = new TreeVector("A", new String[] { "a" }); JTree tree = new JTree(rootVector); tree.setRootVisible(true);/*from w w w. ja v a 2s.c om*/ TreeModel model = tree.getModel(); model.valueForPathChanged(new TreePath(model.getRoot()), "javax.swing"); ((DefaultTreeModel) model).reload(); JScrollPane scrollPane = new JScrollPane(tree); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 300); frame.setVisible(true); }