本文整理汇总了Java中javax.swing.tree.TreeNode.isLeaf方法的典型用法代码示例。如果您正苦于以下问题:Java TreeNode.isLeaf方法的具体用法?Java TreeNode.isLeaf怎么用?Java TreeNode.isLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.TreeNode
的用法示例。
在下文中一共展示了TreeNode.isLeaf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: findString
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
public static boolean findString(ProfilerTable table, String text, boolean matchCase, boolean next) {
int rowCount = table.getRowCount();
ProfilerTreeTable treeTable = null;
if (rowCount == 0) {
ProfilerDialogs.displayWarning(MSG_NODATA, ACTION_FIND, null);
return false;
} else if (rowCount == 1) {
if (!(table instanceof ProfilerTreeTable)) return false;
treeTable = (ProfilerTreeTable)table;
TreeNode node = treeTable.getValueForRow(0);
if (node == null || node.isLeaf()) return false;
}
if (treeTable != null || table instanceof ProfilerTreeTable) {
if (treeTable == null) treeTable = (ProfilerTreeTable)table;
return findString(treeTable, text, matchCase, next, null);
} else {
table.putClientProperty(LAST_FIND_TEXT, text);
table.putClientProperty(LAST_FIND_MATCH_CASE, matchCase);
if (!matchCase) text = text.toLowerCase();
int mainColumn = table.convertColumnIndexToView(table.getMainColumn());
int selectedRow = table.getSelectedRow();
boolean fromSelection = selectedRow != -1;
if (!fromSelection) selectedRow = next ? 0 : rowCount - 1;
else selectedRow = next ? table.getNextRow(selectedRow) :
table.getPreviousRow(selectedRow);
int searchSteps = fromSelection ? rowCount - 1 : rowCount;
for (int i = 0; i < searchSteps; i++) {
String value = table.getStringValue(selectedRow, mainColumn);
if (!matchCase) value = value.toLowerCase();
if (value.contains(text)) {
table.selectRow(selectedRow, true);
return true;
}
selectedRow = next ? table.getNextRow(selectedRow) :
table.getPreviousRow(selectedRow);
}
ProfilerDialogs.displayInfo(MSG_NOTFOUND, ACTION_FIND, null);
return false;
}
}
示例4: getLastLeaf
import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
* Finds and returns the last leaf that is a descendant of this node --
* either this node or its last child's last leaf. Returns this node if it
* is a leaf.
*
* @param node
* @see #isLeaf
* @see #isNodeDescendant
* @return the last leaf in the subtree rooted at this node
*/
public TreeNode getLastLeaf(TreeNode node) {
while (!node.isLeaf()) {
node = getLastChild(node);
}
return node;
}