Package javax.swing.tree

Examples of javax.swing.tree.DefaultTreeModel


            }

            // Redraw this node, so that the entire name appears, necessary if
            // the name is made longer and to avoid the "..." that would be
            // drawn as a result.
            DefaultTreeModel model = (DefaultTreeModel)cellHierarchyTree.getModel();
            if (parentNode != null) {
                model.nodeStructureChanged(parentNode);
            }
            model.nodeChanged(this);

            // Make sure selected node is still selected
            TreePath treePath = new TreePath(getPath());
            cellHierarchyTree.setSelectionPath(treePath);
           
View Full Code Here


                    tc.setPreferredWidth(100);
                    break;
            }
        }

        editPermsTree.setModel(new DefaultTreeModel(edit));
        editPermsTree.addTreeSelectionListener(new TreeSelectionListener() {

            public void valueChanged(TreeSelectionEvent e) {
                TreePath path = e.getPath();
                if (path == null) {
View Full Code Here

                }
            }
        }

        // reset the model on the tree
        editPermsTree.setModel(new DefaultTreeModel(edit));
        editPermPermCombo.setEnabled(false);
        editPermPermCombo.setSelectedIndex(0);
        editPermDescription.setText(BUNDLE.getString("Choose_Permission"));

        // expand the tree
View Full Code Here

      @Override
      public void onClick(final AjaxRequestTarget target)
      {
        treeTable.modelChanging();
        DefaultTreeModel model = (DefaultTreeModel)treeTable.getDefaultModelObject();
        model.removeNodeFromParent(c3);
        model.insertNodeInto(c3, c2, model.getChildCount(c2));
        treeTable.modelChanged();
        treeTable.nodeSelected(c2);
        treeTable.updateTree(target);
      }
    });
View Full Code Here

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode c1 = new DefaultMutableTreeNode("c1");
    c2 = new DefaultMutableTreeNode("c2");
    c3 = new DefaultMutableTreeNode("c3");
    DefaultMutableTreeNode cc2 = new DefaultMutableTreeNode("cc2");
    DefaultTreeModel model = new DefaultTreeModel(root);
    model.insertNodeInto(c1, root, 0);
    model.insertNodeInto(c2, root, 1);
    model.insertNodeInto(cc2, c2, 0);
    model.insertNodeInto(c3, root, 2);
    return model;
  }
View Full Code Here

         *
         * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
         */
        public void valueChanged(TreeSelectionEvent e) {
            final JTree sourceTree = (JTree) e.getSource();
            final DefaultTreeModel treeModel = (DefaultTreeModel) sourceTree
                    .getModel();

            TreePath path = e.getPath();

            if (path == null) { return; }
            final DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode) path
                    .getLastPathComponent();

            // TODO this method will NEVER remove the children and repopulates
            // if the node already has
            // children, be nice to find out
            // whether VFS can help determine whether it should 'relook' for
            // changes or something.

            if (lastPathComponent == null) {
                return;
            } else if (lastPathComponent.getChildCount() > 0) {
                // already determined Children
                return;
            }

            Object userObject = lastPathComponent.getUserObject();
            if (userObject == null || !(userObject instanceof VFSNode)) { return; }
            final VFSNode vfsNode = (VFSNode) userObject;
            Thread thread = new Thread(new Runnable() {

                public void run() {
                    USER_MESSAGE_LOGGER.info("Scanning directory...");
                    sourceTree.setCursor(Cursor
                            .getPredefinedCursor(Cursor.WAIT_CURSOR));
                    lastPathComponent.removeAllChildren();
                    new BackgroundChildFileObjectPopulator(lastPathComponent,
                            vfsNode).run();
                    treeModel.reload(lastPathComponent);
                    sourceTree.setCursor(Cursor.getDefaultCursor());
                }
            });
            thread.setPriority(Thread.MIN_PRIORITY);
            thread.start();
View Full Code Here

   * @see org.apache.log4j.chainsaw.AbstractPreferencePanel#createTreeModel()
   */
  protected TreeModel createTreeModel() {
    final DefaultMutableTreeNode rootNode =
      new DefaultMutableTreeNode("Preferences");
    DefaultTreeModel model = new DefaultTreeModel(rootNode);

    DefaultMutableTreeNode general =
      new DefaultMutableTreeNode(new GeneralAllPrefPanel());

    DefaultMutableTreeNode visuals =
View Full Code Here

    /** */
    public TestPage()
    {
      rootNode = new DefaultMutableTreeNode("ROOT");
      treeModel = new DefaultTreeModel(rootNode);
      tree = new LinkTree("tree", treeModel);
      add(tree);
      add(new AjaxLink<Void>("addToRoot")
      {
        private static final long serialVersionUID = 1L;
View Full Code Here

  private TreeModel convertToTreeModel(List<Object> list)
  {
    TreeModel model = null;
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("<root>");
    add(rootNode, list);
    model = new DefaultTreeModel(rootNode);
    return model;
  }
View Full Code Here

        /* Create the tree model with a root node. The latter is
         * invisible but it must be present because a tree model
         * always needs a root. */
        rootNode = new DefaultMutableTreeNode("POI Filesystems");
        DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);

        /* Create the tree UI element. */
        final JTree treeUI = new JTree(treeModel);
        getContentPane().add(new JScrollPane(treeUI));

View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultTreeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.