本文整理汇总了Java中javax.swing.JTree.isExpanded方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.isExpanded方法的具体用法?Java JTree.isExpanded怎么用?Java JTree.isExpanded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.isExpanded方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import javax.swing.JTree; //导入方法依赖的package包/类
/** Configures a tree cell renderer and sets up sizing and the
* backing image from it */
public boolean configure (Object nd, JScrollPane tv, JTree tree, TreePath path, int row) {
boolean sameVn = setLastRendereredObject(nd);
boolean sameComp = setLastRenderedScrollPane (tv);
Component renderer = null;
bg = tree.getBackground();
boolean sel = tree.isSelectionEmpty() ? false :
tree.getSelectionModel().isPathSelected(path);
boolean exp = tree.isExpanded(path);
boolean leaf = !exp && tree.getModel().isLeaf(nd);
boolean lead = path.equals(tree.getSelectionModel().getLeadSelectionPath());
renderer = tree.getCellRenderer().getTreeCellRendererComponent(tree, nd, sel, exp, leaf, row, lead);
if (renderer != null) {
setComponent (renderer, tree);
}
return true;
}
示例2: saveExpansionState
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* Saves the currently selected paths and saves all expanded repositories and nodes.
*
* @param tree
* The related tree, containing the path(s)
*/
public void saveExpansionState(JTree tree) {
saveSelectionPaths(tree.getSelectionPaths());
expandedNodes = new HashSet<>();
expandedRepositories = new HashSet<>();
for (int i = 0; i < tree.getRowCount(); i++) {
TreePath path = tree.getPathForRow(i);
if (tree.isExpanded(path)) {
Entry entry = (Entry) path.getLastPathComponent();
String absoluteLocation = entry.getLocation().getAbsoluteLocation();
if (entry instanceof Repository) {
expandedRepositories.add(absoluteLocation);
} else {
expandedNodes.add(absoluteLocation);
}
}
}
}
示例3: getExpandedPaths
import javax.swing.JTree; //导入方法依赖的package包/类
public static ArrayList<String> getExpandedPaths(JTree tree) {
ArrayList<String> paths_expanded = new ArrayList<>();
for(int i = 0; i < tree.getRowCount(); i++) {
TreePath tp = tree.getPathForRow(i);
if(tree.isExpanded(i)) {
paths_expanded.add(tp.toString());
}
}
return paths_expanded;
}