Example usage for javax.swing.tree TreeModel valueForPathChanged

List of usage examples for javax.swing.tree TreeModel valueForPathChanged

Introduction

In this page you can find the example usage for javax.swing.tree TreeModel valueForPathChanged.

Prototype

public void valueForPathChanged(TreePath path, Object newValue);

Source Link

Document

Messaged when the user has altered the value for the item identified by path to newValue.

Usage

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);
}