Package javax.swing.tree

Examples of javax.swing.tree.DefaultTreeModel


        addNotify();
  setSize(getInsets().left + getInsets().right + 485,
    getInsets().top + getInsets().bottom + 367);
        setTitle("DistributedTree");
       
        tree_model=new DefaultTreeModel(root);
        jtree=new JTree(tree_model);
        jtree.setDoubleBuffered(true);
 
        scroll_pane=new JScrollPane();
        scroll_pane.getViewport().add(jtree);
View Full Code Here


    private static TreeModel nodes() {
      MutableTreeNode root = node("root",
          node("branch1", node("branch1.1", node("branch1.1.1"), node("branch1.1.2")), node("branch1.2")),
          node("branch2"), node("branch3"), node("branch4"), node("branch5", node("branch5.1")));
      return new DefaultTreeModel(root);
    }
View Full Code Here

          node("branch2"));
      return root;
    }

    private static TreeModel nodes(MutableTreeNode root) {
      return new DefaultTreeModel(root);
    }
View Full Code Here

    final TestTree tree = new TestTree(nodes());

    private static TreeModel nodes() {
      MutableTreeNode root = node("root", node("a", node("b", node("c"))));
      return new DefaultTreeModel(root);
    }
View Full Code Here

      MutableTreeNode root = node("root", node("branch1", node("branch1.1"), node("branch1.2")), node("branch2"));
      return root;
    }

    private static TreeModel nodes(MutableTreeNode root) {
      return new DefaultTreeModel(root);
    }
View Full Code Here

    final JTree tree = new JTree();
    final MutableTreeNode nodeToSelect = node("node111");

    private MyWindow() {
      super(Bug263_separatorNotRespectedInJTree_Test.class);
      tree.setModel(new DefaultTreeModel(root()));
      tree.setPreferredSize(new Dimension(200, 200));
      add(tree);
    }
View Full Code Here

      scrollPane.setPreferredSize(new Dimension(100, 100));
      return scrollPane;
    }

    private static DefaultTreeModel model() {
      return new DefaultTreeModel(rootWith100Nodes());
    }
View Full Code Here

      return b.toString();
    }

    @Override
    protected void importString(JTree target, String s) {
      DefaultTreeModel model = (DefaultTreeModel) target.getModel();
      int index = target.getRowForPath(target.getSelectionPath());
      // Prevent the user from dropping data back on itself.
      if (rows != null && index >= rows[0] - 1 && index <= rows[rows.length - 1]) {
        rows = null;
        return;
      }
      int max = target.getRowCount();
      if (index < 0) {
        index = max;
      } else if (index > max) {
        index = max;
      }
      addIndex = index;
      String[] values = s.split("\n");
      addCount = values.length;
      for (String value : values) {
        TreePath path = target.getPathForRow(index++);
        model.insertNodeInto(new DefaultMutableTreeNode(value), (MutableTreeNode) path.getLastPathComponent(), 0);
      }
    }
View Full Code Here

    // not working perfectly right, but good enough for testing.
    @Override
    protected void cleanup(JTree source, boolean remove) {
      if (remove && rows != null) {
        DefaultTreeModel model = (DefaultTreeModel) source.getModel();
        // If we are moving items around in the same table, we need to adjust the rows accordingly, since those after
        // the
        // insertion point have moved.
        if (addCount > 0) {
          for (int i = 0; i < rows.length; i++) {
            if (rows[i] > addIndex) {
              rows[i] += addCount;
            }
          }
        }
        for (int i = rows.length - 1; i >= 0; i--) {
          TreePath path = source.getPathForRow(rows[i]);
          if (path == null) {
            continue;
          }
          model.removeNodeFromParent((MutableTreeNode) path.getLastPathComponent());
        }
      }
    }
View Full Code Here

    private static TreeModel nodes() {
      MutableTreeNode root = node("root",
          node("branch1", node("branch1.1", node("branch1.1.1"), node("branch1.1.2")), node("branch1.2")),
          node("branch2"));
      return new DefaultTreeModel(root);
    }
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.