本文整理汇总了Java中javax.swing.tree.TreeNode.children方法的典型用法代码示例。如果您正苦于以下问题:Java TreeNode.children方法的具体用法?Java TreeNode.children怎么用?Java TreeNode.children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.TreeNode
的用法示例。
在下文中一共展示了TreeNode.children方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTreePath
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
public static TreePath getTreePath(JTreeOperator treeOperator, String targetNode, NodeConverter converter) {
Stack<TreeNode> lifo = new Stack<TreeNode>();
lifo.push((TreeNode) treeOperator.getRoot());
while(!lifo.isEmpty()) {
TreeNode actNode = lifo.pop();
if(targetNode.equals(converter.getDisplayName(actNode))) {
List<TreeNode> path = new LinkedList<TreeNode>();
path.add(actNode);
actNode = actNode.getParent();
while(actNode!=null) {
path.add(0,actNode);
actNode = actNode.getParent();
}
TreeNode[] res = path.toArray(new TreeNode[path.size()]);
return new TreePath(res);
}
final Enumeration children = actNode.children();
while(children.hasMoreElements()) {
lifo.add((TreeNode)children.nextElement());
}
}
return null;
}
示例2: OntoTreeExpand
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private void OntoTreeExpand( TreePath parent, boolean expand, Integer CurrNodeLevel, Integer Up2TreeLevel) {
TreeNode node = (TreeNode)parent.getLastPathComponent();
if (CurrNodeLevel >= Up2TreeLevel) {
return;
}
if (node.getChildCount() >= 0) {
for (Enumeration<?> e=node.children(); e.hasMoreElements();) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
OntoTreeExpand(path, expand, CurrNodeLevel+1, Up2TreeLevel);
}
}
// Expansion or collapse must be done bottom-up
if (expand) {
ontoTree.expandPath(parent);
} else {
ontoTree.collapsePath(parent);
}
}
示例3: OntoTreeExpand
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
*
* @param parent
* @param expand
* @param CurrNodeLevel
* @param Up2TreeLevel
*/
private void OntoTreeExpand(TreePath parent, boolean expand, Integer CurrNodeLevel, Integer Up2TreeLevel) {
TreeNode node = (TreeNode)parent.getLastPathComponent();
if (CurrNodeLevel >= Up2TreeLevel) {
return;
}
if (node.getChildCount() >= 0) {
for ( Enumeration<?> e=node.children(); e.hasMoreElements(); ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
OntoTreeExpand(path, expand, CurrNodeLevel+1, Up2TreeLevel);
}
}
// Expansion or collapse must be done bottom-up
if (expand) {
jTreeOntology.expandPath(parent);
} else {
jTreeOntology.collapsePath(parent);
}
}
示例4: projectTreeExpand
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
* Project tree expand.
*
* @param parent the parent
* @param expand the expand
* @param currNodeLevel the current node level
* @param up2TreeLevel the up2 tree level
*/
private void projectTreeExpand(TreePath parent, boolean expand, Integer currNodeLevel, Integer up2TreeLevel) {
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (currNodeLevel >= up2TreeLevel) {
return;
}
if (node.getChildCount() >= 0) {
for (@SuppressWarnings("rawtypes")
Enumeration e = node.children(); e.hasMoreElements();) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
projectTreeExpand(path, expand, currNodeLevel + 1, up2TreeLevel);
}
}
// Expansion or collapse must be done bottom-up
if (expand) {
jTreeProject.expandPath(parent);
} else {
jTreeProject.collapsePath(parent);
}
}
示例5: optionTreeExpand
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
* Option tree expand.
*
* @param parent the parent
* @param expand the expand
* @param currNodeLevel the curr node level
* @param up2TreeLevel the up2 tree level
*/
private void optionTreeExpand(TreePath parent, boolean expand, Integer currNodeLevel, Integer up2TreeLevel) {
TreeNode node = (TreeNode)parent.getLastPathComponent();
if (currNodeLevel >= up2TreeLevel) {
return;
}
if (node.getChildCount() >= 0) {
for ( @SuppressWarnings("rawtypes") Enumeration e=node.children(); e.hasMoreElements(); ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
optionTreeExpand(path, expand, currNodeLevel+1, up2TreeLevel);
}
}
// Expansion or collapse must be done bottom-up
if (expand) {
jTreeOptions.expandPath(parent);
} else {
jTreeOptions.collapsePath(parent);
}
}
示例6: expandAll
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private void expandAll(JTree tree, TreePath path, boolean expand) {
TreeNode node = (TreeNode) path.getLastPathComponent();
if (node.getChildCount() >= 0) {
Enumeration enumeration = node.children();
while (enumeration.hasMoreElements()) {
TreeNode n = (TreeNode) enumeration.nextElement();
TreePath p = path.pathByAddingChild(n);
expandAll(tree, p, expand);
}
}
if (expand) {
tree.expandPath(path);
} else {
tree.collapsePath(path);
}
}
示例7: expandOrCollapseAll
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private void expandOrCollapseAll(TreePath parent, boolean expand) {
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.getChildCount() > 0) {
for (Enumeration<? extends TreeNode> e = node.children(); e.hasMoreElements();) {
TreeNode n = e.nextElement();
TreePath path = parent.pathByAddingChild(n);
expandOrCollapseAll(path, expand);
}
}
if (expand) {
tree.expandPath(parent);
} else {
tree.collapsePath(parent);
}
}
示例8: expandAll
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
public static void expandAll(Tree tree, TreePath parent, boolean expand) {
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.getChildCount() >= 0) {
for (Enumeration e = node.children() ; e.hasMoreElements() ; ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
expandAll(tree, path, expand);
}
}
if (expand) {
tree.expandPath(parent);
} else {
tree.collapsePath(parent);
}
}
示例9: expandChildPathsAndSelectParent
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private void expandChildPathsAndSelectParent(TreeNode parent)
{
for( Enumeration<?> en = parent.children(); en.hasMoreElements(); )
{
TreeNode child = (TreeNode) en.nextElement();
tree.expandPath(new TreePath(model.getPathToRoot(child)));
}
TreePath parentPath = new TreePath(model.getPathToRoot(parent));
tree.expandPath(parentPath);
tree.setSelectionPath(parentPath);
}
示例10: expandTreeRecursively
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private static void expandTreeRecursively(JTree tree, TreePath parent) {
tree.expandPath(parent);
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.getChildCount() >= 0) {
for (Enumeration e = node.children(); e.hasMoreElements(); ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
expandTreeRecursively(tree, path);
}
}
}
示例11: expandAll
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private void expandAll(final JTree tree, final TreePath parent) {
final TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.getChildCount() >= 0) {
for (@SuppressWarnings("rawtypes")
final Enumeration e = node.children(); e.hasMoreElements();) {
final TreeNode n = (TreeNode) e.nextElement();
final TreePath path = parent.pathByAddingChild(n);
this.expandAll(tree, path);
}
}
tree.expandPath(parent);
// tree.collapsePath(parent);
}