Example usage for javax.swing.tree TreeModel addTreeModelListener

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

Introduction

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

Prototype

void addTreeModelListener(TreeModelListener l);

Source Link

Document

Adds a listener for the TreeModelEvent posted after the tree changes.

Usage

From source file:plugin.notes.gui.NotesView.java

private void initTree() {
    dataDir.listFiles();/*from w  w  w. ja  va 2  s . c  o  m*/
    root = new NotesTreeNode(dataDir.getName(), dataDir, notesTree);

    TreeModel model = new DefaultTreeModel(root);
    notesTree.setModel(model);
    notesTree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent evt) {
            notesTreeActionPerformed();
        }
    });
    notesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    notesTree.setEditable(true);
    model.addTreeModelListener(new TreeModelListener() {
        @Override
        public void treeNodesChanged(TreeModelEvent e) {
            notesTreeNodesChanged();
        }

        @Override
        public void treeNodesInserted(TreeModelEvent e) {
            // TODO:  Method does nothing?
        }

        @Override
        public void treeNodesRemoved(TreeModelEvent e) {
            // TODO:  Method does nothing?
        }

        @Override
        public void treeStructureChanged(TreeModelEvent e) {
            // TODO:  Method does nothing?
        }
    });
}