本文整理汇总了Java中javax.swing.tree.TreeNode.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java TreeNode.getChildCount方法的具体用法?Java TreeNode.getChildCount怎么用?Java TreeNode.getChildCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.TreeNode
的用法示例。
在下文中一共展示了TreeNode.getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: areSiblingsFullyChecked
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private boolean areSiblingsFullyChecked() {
TreeNode parent = getParent();
for (int i = 0; i < parent.getChildCount(); i++) {
TreeNode node = parent.getChildAt(i);
if (node == this) {
continue;
}
if (!(node instanceof CheckTreeNode) || (((CheckTreeNode) node).getCheckState() != STATE_CHECKED)) {
return false;
}
}
return true;
}
示例2: areSiblingsUnchecked
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private boolean areSiblingsUnchecked() {
TreeNode parent = getParent();
for (int i = 0; i < parent.getChildCount(); i++) {
TreeNode node = parent.getChildAt(i);
if (node == this) {
continue;
}
if (!(node instanceof CheckTreeNode) || (((CheckTreeNode) node).getCheckState() != STATE_UNCHECKED)) {
return false;
}
}
return true;
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: mousePressed
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
@Override protected void mousePressed(MouseEvent me) {
// Ignore double clicks on non-leaf tree nodes
if (me.getButton() == MouseEvent.BUTTON1 && me.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK) {
if (me.getClickCount() == 1) {
return;
}
TreePath path = ((JTree) component).getPathForRow(row);
if (path != null) {
Object lastPathComponent = path.getLastPathComponent();
if (lastPathComponent instanceof TreeNode) {
TreeNode node = (TreeNode) lastPathComponent;
if (node.getChildCount() != 0) {
return;
}
}
}
}
// Ignore Ctrl+Clicks used to select the nodes
if (me.getButton() == MouseEvent.BUTTON1 && isMenuShortcutKeyDown(me)) {
return;
}
if (me.getButton() != MouseEvent.BUTTON1) {
focusLost(null);
}
super.mousePressed(me);
}
示例7: find
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
* Retrieves the child of a given parent node that is
* a numbered tree node with a given number, if any.
* @return the correctly numbered child, or {@code null} if there
* is none such
*/
private NumberedTreeNode find(TreeNode parent, int number) {
NumberedTreeNode result = null;
int lower = 0;
int upper = parent.getChildCount() - 1;
boolean found = false;
while (!found && lower <= upper) {
int mid = (lower + upper) / 2;
result = (NumberedTreeNode) parent.getChildAt(mid);
int resultNumber = result.getNumber();
if (result.contains(number)) {
found = true;
} else if (resultNumber < number) {
lower = mid + 1;
} else if (resultNumber > number) {
upper = mid - 1;
}
}
return found ? result : null;
}
示例8: execute
import javax.swing.tree.TreeNode; //导入方法依赖的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);
}
}
}
示例9: getChildAfter
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
* Returns the child in this node's child array that immediately follows
* <code>aChild</code>, which must be a child of this node. If
* <code>aChild</code> is the last child, returns null. This method performs
* a linear search of this node's children for <code>aChild</code> and is
* O(n) where n is the number of children; to traverse the entire array of
* children, use an enumeration instead.
*
* @param parent
* @param aChild
* @see #children
* @exception IllegalArgumentException if <code>aChild</code> is null or is
* not a child of this node
* @return the child of this node that immediately follows
* <code>aChild</code>
*/
public TreeNode getChildAfter(TreeNode parent, TreeNode aChild) {
if (aChild == null) {
throw new IllegalArgumentException("argument is null");
}
int index = parent.getIndex(aChild); // linear search
if (index == -1) {
throw new IllegalArgumentException("node is not a child");
}
if (index < parent.getChildCount() - 1) {
return parent.getChildAt(index + 1);
} else {
return null;
}
}
示例10: treeExpanded
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
@Override
public void treeExpanded(final TreeExpansionEvent event) {
final TreePath treePath = event.getPath();
final Object expandedTreePathObject = treePath.getLastPathComponent();
if (!(expandedTreePathObject instanceof TreeNode)) {
return;
}
final TreeNode expandedTreeNode = (TreeNode) expandedTreePathObject;
if (expandedTreeNode.getChildCount() == 1) {
final TreeNode descendantTreeNode = expandedTreeNode.getChildAt(0);
if (descendantTreeNode.isLeaf()) {
return;
}
final TreePath nextTreePath = treePath.pathByAddingChild(descendantTreeNode);
tree.expandPath(nextTreePath);
}
}
示例11: 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);
}
}
示例12: getSelectedNodes
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private List<StoreEntryNode> getSelectedNodes(TreeNode node) {
List<StoreEntryNode> ret = new LinkedList<StoreEntryNode>();
int count = node.getChildCount();
for (int i = 0; i < count; i++) {
TreeNode child = node.getChildAt(i);
if(child instanceof StoreEntryNode) {
StoreEntryNode sen = (StoreEntryNode) child;
if(sen.isSelected()) {
ret.add(sen);
}
}
ret.addAll(getSelectedNodes(child));
}
return ret;
}
示例13: addContributedGrids
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
private void addContributedGrids(Map<String, Rectangle2D.Double> namesToBounds, TreeNode root) {
if (root.isLeaf())
addContributedGrid(namesToBounds, root);
else
for (int i = 0; i < root.getChildCount(); i++) {
TreeNode node = root.getChildAt(i);
addContributedGrids(namesToBounds, node);
}
}
示例14: isNodeChild
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
* Returns true if <code>aNode</code> is a child of this node. If
* <code>aNode</code> is null, this method returns false.
*
* @param parent
* @param aNode
* @return true if <code>aNode</code> is a child of this node; false if
* <code>aNode</code> is null
*/
public boolean isNodeChild(TreeNode parent, TreeNode aNode) {
boolean retval;
if (aNode == null) {
retval = false;
} else if (parent.getChildCount() == 0) {
retval = false;
} else {
retval = (aNode.getParent() == parent);
}
return retval;
}
示例15: configureNodes
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
* A method to configure the nodes in the tree of the method summary
* @param node a parameter to take the node of the tree to configure nodes in it
*/
private void configureNodes(TreeNode node) {
if (node instanceof VisitableNode)
((VisitableNode) node).configureNode();
else if( node != null )
for (int i = 0; i < node.getChildCount(); i++)
configureNodes( node.getChildAt(i));
}