本文整理汇总了Java中javax.swing.tree.DefaultMutableTreeNode.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMutableTreeNode.getChildCount方法的具体用法?Java DefaultMutableTreeNode.getChildCount怎么用?Java DefaultMutableTreeNode.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultMutableTreeNode
的用法示例。
在下文中一共展示了DefaultMutableTreeNode.getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLowerFileModel
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void getLowerFileModel(DefaultMutableTreeNode node) {
if (node instanceof ProjectPanelTreeNode) {
ProjectPanelTreeNode pptn = (ProjectPanelTreeNode)node;
if (pptn.isFolder()) {
for (int i = 0; i < pptn.getChildCount(); i++) {
getLowerFileModel((DefaultMutableTreeNode)pptn.getChildAt(i));
}
}
else if (pptn.isFile()) {
ProjectFileEntry pfe = (ProjectFileEntry)pptn.getObject();
lowerFiles.addElement(pfe);
}
}
else {
for (int i = 0; i < node.getChildCount(); i++) {
getLowerFileModel((DefaultMutableTreeNode)node.getChildAt(i));
}
} }
示例2: getTreeCellRendererComponent
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf,
int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
if (node.getChildCount() > 0) {
setIcon(this.pack);
} else if (getFileName(node).endsWith(".class") || getFileName(node).endsWith(".java")) {
setIcon(this.java_image);
} else if (getFileName(node).endsWith(".yml") || getFileName(node).endsWith(".yaml")) {
setIcon(this.yml_image);
} else {
setIcon(this.file_image);
}
return this;
}
示例3: 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;
}
示例4: isSelected
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
State isSelected( DefaultMutableTreeNode node ) {
boolean hasEnabled = false;
boolean hasDisabled = false;
List<DefaultMutableTreeNode> todo = new LinkedList<>();
todo.add(node);
while (!todo.isEmpty()) {
DefaultMutableTreeNode current = todo.remove(0);
Object o = current.getUserObject();
if ( o instanceof HintMetadata ) {
HintMetadata hint = (HintMetadata)o;
if (isEnabled(hint)) {
hasEnabled = true;
} else {
hasDisabled = true;
}
} else if (o instanceof HintCategory) {
for (int i = 0; i < current.getChildCount(); i++) {
todo.add((DefaultMutableTreeNode) current.getChildAt(i));
}
}
}
return hasEnabled ? hasDisabled ? State.OTHER : State.SELECTED : State.NOT_SELECTED;
}
示例5: retrieveDeletedFiles
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void retrieveDeletedFiles(final Node[] activatedNodes, final RevertPanel p) {
VCSContext ctx = VCSContext.forNodes(activatedNodes);
Set<VCSFileProxy> rootSet = ctx.getRootFiles();
if(rootSet == null || rootSet.size() < 1) {
return;
}
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
for (VCSFileProxy root : rootSet) {
PlainFileNode rfn = new PlainFileNode(root);
populateNode(rfn, root, !VersioningSupport.isFlat(root));
if(rfn.getChildCount() > 0) {
rootNode.add(rfn);
}
}
if(rootNode.getChildCount() > 0) {
p.setRootNode(rootNode);
} else {
p.setRootNode(null);
}
}
示例6: getTreeCellRendererComponent
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf,
int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
if (node.getChildCount() > 0) {
setIcon(this.pack);
} else if (getFileName(node).endsWith(".class") || getFileName(node).endsWith(".java")) {
setIcon(this.java_image);
} else if (getFileName(node).endsWith(".yml") || getFileName(node).endsWith(".yaml")) {
setIcon(this.yml_image);
} else {
setIcon(this.file_image);
}
return this;
}
示例7: haveCompleteNode
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private boolean haveCompleteNode(JTree tree) {
int[] selRows = tree.getSelectionRows();
TreePath path = tree.getPathForRow(selRows[0]);
DefaultMutableTreeNode first =
(DefaultMutableTreeNode)path.getLastPathComponent();
int childCount = first.getChildCount();
// first has children and no children are selected.
if(childCount > 0 && selRows.length == 1)
return false;
// first may have children.
for(int i = 1; i < selRows.length; i++) {
path = tree.getPathForRow(selRows[i]);
DefaultMutableTreeNode next =
(DefaultMutableTreeNode)path.getLastPathComponent();
if(first.isNodeChild(next)) {
// Found a child of first.
if(childCount > selRows.length-1) {
// Not all children of first are selected.
return false;
}
}
}
return true;
}
示例8: FmtSpaces
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/** Creates new form FmtSpaces */
private FmtSpaces() {
initComponents();
model = createModel();
cfgTree.setModel(model);
cfgTree.setRootVisible(false);
cfgTree.setShowsRootHandles(true);
cfgTree.setCellRenderer(this);
cfgTree.setEditable(false);
cfgTree.addMouseListener(this);
cfgTree.addKeyListener(this);
dr.setIcon(null);
dr.setOpenIcon(null);
dr.setClosedIcon(null);
DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
for( int i = root.getChildCount(); i >= 0; i-- ) {
cfgTree.expandRow(i);
}
}
示例9: sortNodesDescending
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Sort nodes descending.
*
* @param node the node
* @param treeModel the tree model
*/
private void sortNodesDescending(DefaultMutableTreeNode node, DefaultTreeModel treeModel) {
boolean unsorted = true;
while (unsorted) {
unsorted = false;
for (int i = 0; i < node.getChildCount() - 1; i++) {
ThreadInfoStorageAgent tiaFirst = (ThreadInfoStorageAgent) ((DefaultMutableTreeNode) node.getChildAt(i)).getUserObject();
ThreadInfoStorageAgent tiaSecond = (ThreadInfoStorageAgent) ((DefaultMutableTreeNode) node.getChildAt(i+1)).getUserObject();
if (tiaFirst.getXYSeriesMap().get("TOTAL_CPU_SYSTEM_TIME").getMaxY() < tiaSecond.getXYSeriesMap().get("TOTAL_CPU_SYSTEM_TIME").getMaxY()) {
treeModel.insertNodeInto((MutableTreeNode) node.getChildAt(i+1), node, i);
unsorted = true;
}
}
}
}
示例10: getMultipleNodesAvailable
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Provides the Vector of all currently available nodes of the same kind as the current node.
*
* @param currNode The current node of the object structure
* @return the multiple nodes available
*/
private Vector<DefaultMutableTreeNode> getMultipleNodesAvailable(DefaultMutableTreeNode currNode) {
// --- The result vector of all needed nodes ------------------------------------
Vector<DefaultMutableTreeNode> nodesFound = new Vector<DefaultMutableTreeNode>();
// --- Can we find the number of similar nodes to the current one? --------------
DynType currDT = (DynType) currNode.getUserObject();
// --- The current parentNode and the position of the current node --------------
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) currNode.getParent();
// --- Search for all similar nodes ---------------------------------------------
for (int i = 0; i < parentNode.getChildCount(); i++) {
DefaultMutableTreeNode checkNode = (DefaultMutableTreeNode) parentNode.getChildAt(i);
DynType checkDT = (DynType) checkNode.getUserObject();
if (checkDT.equals(currDT)) {
nodesFound.add(checkNode);
}
}
return nodesFound;
}
示例11: getTopLevelIndicators
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public AIndicator[][] getTopLevelIndicators()
{
AIndicator[][] indicators = new AIndicator[rootNodes.length][];
int k = 0;
for(DefaultMutableTreeNode tn: rootNodes)
{
indicators[k] = new AIndicator[tn.getChildCount()];
for(int c = 0;c < tn.getChildCount(); c++)
{
indicators[k][c] = (AIndicator)((DefaultMutableTreeNode)tn.getChildAt(c)).getUserObject();
}
k++;
}
return indicators;
}
示例12: setJPanelInvisibleAndSmall
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Sets the invisible.
*
* @param parentNode the new invisible
* @return the rectangle
*/
private Rectangle setJPanelInvisibleAndSmall(DefaultMutableTreeNode parentNode) {
Rectangle feBounds = null; // --- First element Bounds ------
DynType parentDT = (DynType) parentNode.getUserObject();
for (int i = 0; i < parentNode.getChildCount(); i++) {
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) parentNode.getChildAt(i);
if (childNode.getChildCount()>0) {
// --- recursively edit all sub panels --------------
feBounds = this.setJPanelInvisibleAndSmall(childNode);
}
DynType dt = (DynType) childNode.getUserObject();
if (feBounds==null) {
feBounds = dt.getPanel().getBounds();
}
dt.getPanel().setVisible(false);
dt.getPanel().setBounds(feBounds);
}
this.setPanelBounds(parentDT.getPanel());
return feBounds;
}
示例13: updateGui
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Update the visualizer with new data.
*/
private synchronized void updateGui(SampleResult res) {
// Add sample
DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel);
treeModel.insertNodeInto(currNode, root, root.getChildCount());
addSubResults(currNode, res);
// Add any assertion that failed as children of the sample node
AssertionResult[] assertionResults = res.getAssertionResults();
int assertionIndex = currNode.getChildCount();
for (AssertionResult assertionResult : assertionResults) {
if (assertionResult.isFailure() || assertionResult.isError()) {
DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult, treeModel);
treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++);
}
}
if (root.getChildCount() == 1) {
jTree.expandPath(new TreePath(root));
}
if (autoScrollCB.isSelected() && root.getChildCount() > 1) {
jTree.scrollPathToVisible(new TreePath(new Object[] { root,
treeModel.getChild(root, root.getChildCount() - 1) }));
}
}
示例14: findNode
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private DefaultMutableTreeNode findNode(DefaultMutableTreeNode parent, String userObject) {
for (int i=0; i<parent.getChildCount(); i++) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode)parent.getChildAt(i);
if (userObject.equals(child.getUserObject())) {
return child;
}
}
return null;
}
示例15: addProjectTabInternal
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Adds a Project-Tab and a new node (child of a specified parent) to the ProjectWindow.
*
* @param projectWindowTab the project window tab
* @return the default mutable tree node
*/
private DefaultMutableTreeNode addProjectTabInternal(ProjectWindowTab projectWindowTab) {
// --- create Node ----------------------
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(projectWindowTab);
DefaultMutableTreeNode pareNode = null;
JTabbedPane tabbedPaneParent = null;
String parentName = projectWindowTab.getParentName();
// --- add to the TreeModel -------------
if (parentName != null) {
pareNode = getTreeNode(parentName);
ProjectWindowTab pareNodePWT = (ProjectWindowTab) pareNode.getUserObject();
tabbedPaneParent = pareNodePWT.getCompForChildComp();
// --- add ChangeListener -----------
this.addChangeListener(tabbedPaneParent);
} else {
pareNode = this.getRootNode();
tabbedPaneParent = projectViewRightTabs;
}
if (projectWindowTab.getIndexPosition() != -1 && projectWindowTab.getIndexPosition() < pareNode.getChildCount()) {
// --- Add to parent node/tab at index position ----
pareNode.insert(newNode, projectWindowTab.getIndexPosition());
tabbedPaneParent.insertTab(projectWindowTab.getTitle(), projectWindowTab.getIcon(), projectWindowTab.getJComponentForVisualization(), projectWindowTab.getTipText(), projectWindowTab.getIndexPosition());
} else {
// --- Just add to parent node/tab -----------------
pareNode.add(newNode);
tabbedPaneParent.addTab(projectWindowTab.getTitle(), projectWindowTab.getIcon(), projectWindowTab.getJComponentForVisualization(), projectWindowTab.getTipText());
}
// --- refresh view ---------------------
this.getTreeModel().reload();
this.projectTreeExpand2Level(3, true);
return newNode;
}