当前位置: 首页>>代码示例>>Java>>正文


Java DefaultMutableTreeNode.getPath方法代码示例

本文整理汇总了Java中javax.swing.tree.DefaultMutableTreeNode.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMutableTreeNode.getPath方法的具体用法?Java DefaultMutableTreeNode.getPath怎么用?Java DefaultMutableTreeNode.getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.tree.DefaultMutableTreeNode的用法示例。


在下文中一共展示了DefaultMutableTreeNode.getPath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPath

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private TreeNode[] getPath(Object node, String deap, String item, boolean debug) {
    if (node instanceof DefaultMutableTreeNode) {
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) node;
        if (debug) {
            System.out.println(deap + dmtn.toString());
        }
        if (dmtn.toString().equals(item)) {
            if (debug) {
                System.out.println("EQUAL!!! <" + item + ">");
            }
            return dmtn.getPath();
        }
        TreeNode[] curPath;
        for (int i = 0; i < dmtn.getChildCount(); i++) {
            curPath = getPath(dmtn.getChildAt(i), deap + "__", item, debug);
            if (curPath != null) {
                return curPath;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ManageInspectionsOperatot.java

示例2: addNode

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Recursively adds new nodes to the tree.
 */
protected void addNode(DefaultMutableTreeNode parent, Component component, Component selectedComponent) {
	DefaultMutableTreeNode componentNode = new DefaultMutableTreeNode(new ComponentWrapper(component));
	parent.add(componentNode);
	if (component == selectedComponent) {
		TreePath selectedPath = new TreePath(componentNode.getPath());
		componentTree.setSelectionPath(selectedPath);
		componentTree.scrollPathToVisible(selectedPath);
	}

	if (component instanceof Container) {
		Container container = (Container) component;
		Component[] childComponents = container.getComponents();
		for (Component child : childComponents) {
			addNode(componentNode, child, selectedComponent);
		}
	}
}
 
开发者ID:igr,项目名称:swingspy,代码行数:21,代码来源:SwingSpyPanel.java

示例3: execute

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public void execute() {
    TreeNode root = (TreeNode) this.tree.getModel().getRoot();
    List<DefaultMutableTreeNode> collapsableNodes = new ArrayList<>();
    for (int i = 0; i < root.getChildCount(); i++) {
        TreeNode child = root.getChildAt(i);
        if (isDirectoryNode(child)) {
            for (int j = 0; j < child.getChildCount(); j++) {
                collapsableNodes.add((DefaultMutableTreeNode) child.getChildAt(j));
            }
        } else {
            collapsableNodes.add((DefaultMutableTreeNode) child);
        }
    }
    for (DefaultMutableTreeNode node : collapsableNodes) {
        TreePath path = new TreePath(node.getPath());
        if (!this.tree.isCollapsed(path)) {
            this.tree.collapsePath(path);
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:22,代码来源:CollapseAllAction.java

示例4: intervalAdded

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public void intervalAdded(ListDataEvent e) {
    for (int i = e.getIndex1(); i >= e.getIndex0(); i--) {
        Object obj = listModel.getElementAt(i);
        if (obj instanceof ClassPathSupport.Item) {
            DefaultMutableTreeNode node = toTreeNode(obj);
            treeModel.insertNodeInto(node, (MutableTreeNode)treeModel.getRoot(), e.getIndex0());
            TreePath path = new TreePath(node.getPath());
            tree.setSelectionPath(path);
            tree.makeVisible(path);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:PathsCustomizer.java

示例5: highlight

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
protected void highlight(Collection<DefaultMutableTreeNode> nodes) {
    // Collapse everything and then show the paths to each node
    for (int ctr = this.catalogTree.getRowCount(); ctr >= 0; ctr--) {
        if (this.catalogTree.isExpanded(ctr)) {
            this.catalogTree.collapseRow(ctr);              
        }
    } // FOR
    this.catalogTree.getSelectionModel().clearSelection();
    
    for (DefaultMutableTreeNode node : nodes) {
        TreePath path = new TreePath(node.getPath());
        this.catalogTree.setSelectionPath(path);
        this.catalogTree.expandPath(path);
    } // FOR
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:16,代码来源:CatalogViewer.java

示例6: select

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void select(String id) {
    DefaultMutableTreeNode node = nodeMap.get(id);
    if (node == null) {
        logger.warning("Unable to find node with id '" + id + "'.");
    } else {
        TreePath oldPath = tree.getSelectionPath();
        if (oldPath != null && oldPath.getParentPath() != null) {
            tree.collapsePath(oldPath.getParentPath());
        }
        TreePath newPath = new TreePath(node.getPath());
        tree.scrollPathToVisible(newPath);
        tree.expandPath(newPath);
        showDetails((ColopediaTreeItem) node.getUserObject());
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:16,代码来源:ColopediaPanel.java

示例7: select

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private boolean select(DefaultMutableTreeNode parent, Predicate<IEntity> selectionPredicate) {
  if (parent.getChildCount() == 0) {
    return false;
  }

  Enumeration en = parent.depthFirstEnumeration();
  while (en.hasMoreElements()) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) en.nextElement();
    IEntity ent = null;
    if (node.getUserObject() instanceof IconTreeListItem) {
      IconTreeListItem iconItem = (IconTreeListItem) node.getUserObject();
      if (iconItem.getUserObject() instanceof IEntity) {
        ent = (IEntity) iconItem.getUserObject();
      }
    } else if (node.getUserObject() instanceof IEntity) {
      ent = (IEntity) node.getUserObject();
    }

    if (ent == null) {
      continue;
    }

    if (selectionPredicate.test(ent)) {
      final TreePath newSelection = new TreePath(node.getPath());
      if (this.tree.getSelectionPath() != null && this.tree.getSelectionPath().equals(newSelection)) {
        continue;
      }

      this.tree.setSelectionPath(newSelection);
      TreePath path = this.tree.getSelectionPath();
      if (path == null || !this.tree.isVisible()) {
        return false;
      }

      Rectangle bounds = this.tree.getPathBounds(path);
      if (bounds == null) {
        return false;
      }
      // set the height to the visible height to force the node to top 
      bounds.height = this.tree.getVisibleRect().height;
      this.tree.scrollRectToVisible(bounds);
      return true;
    }
  }

  return false;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:48,代码来源:MapSelectionPanel.java

示例8: createPath

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/** Callback factory method to create a {@link TreePath} object for a node. */
private TreePath createPath(DefaultMutableTreeNode node) {
    return new TreePath(node.getPath());
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:5,代码来源:StateTree.java


注:本文中的javax.swing.tree.DefaultMutableTreeNode.getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。