本文整理了Java中javax.swing.JTree.expandPath()
方法的一些代码示例,展示了JTree.expandPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.expandPath()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:expandPath
暂无
代码示例来源:origin: log4j/log4j
protected void expand(CategoryNode node) {
_tree.expandPath(getTreePath(node));
}
代码示例来源:origin: deathmarine/Luyten
@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);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected void expand(CategoryNode node) {
_tree.expandPath(getTreePath(node));
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected void expandRootNode() {
if (_rootAlreadyExpanded) {
return;
}
_rootAlreadyExpanded = true;
TreePath path = new TreePath(_model.getRootCategoryNode().getPath());
expandPath(path);
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void mousePressed(MouseEvent e) {
int selRow = ManagerDatabase.this.tree.getRowForLocation(e.getX(), e.getY());
TreePath selPath = ManagerDatabase.this.tree.getPathForLocation(e.getX(), e.getY());
if (selRow != -1 && e.getClickCount() == 2) {
if (ManagerDatabase.this.tree.isExpanded(selPath)) {
ManagerDatabase.this.tree.collapsePath(selPath);
} else {
ManagerDatabase.this.tree.expandPath(selPath);
}
}
}
代码示例来源:origin: INRIA/spoon
@Override
public void run() {
TreePath path = new TreePath(node.getPath());
if (!jTree.isExpanded(path)) {
jTree.expandPath(path);
jTree.updateUI();
}
}
});
代码示例来源:origin: pentaho/mondrian
/**
* Call this method whenever you update the tree and needs it reloaded
*/
public synchronized void update() {
synchronized (this.tree) {
this.tree.removeTreeExpansionListener(this);
this.tree.removeTreeSelectionListener(this);
((DefaultTreeModel) this.tree.getModel()).reload();
for (TreePath treePath : expandedTreePaths) {
this.tree.expandPath(treePath);
}
this.tree.getSelectionModel().setSelectionPaths(selectedTreePaths);
this.tree.addTreeExpansionListener(this);
this.tree.addTreeSelectionListener(this);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected void processCategories(Document doc) {
CategoryExplorerTree tree = _monitor.getCategoryExplorerTree();
CategoryExplorerModel model = tree.getExplorerModel();
NodeList nodeList = doc.getElementsByTagName(CATEGORY);
// determine where the starting node is
NamedNodeMap map = nodeList.item(0).getAttributes();
int j = (getValue(map, NAME).equalsIgnoreCase(FIRST_CATEGORY_NAME)) ? 1 : 0;
// iterate backwards throught the nodeList so that expansion of the
// list can occur
for (int i = nodeList.getLength() - 1; i >= j; i--) {
Node n = nodeList.item(i);
map = n.getAttributes();
CategoryNode chnode = model.addCategory(new CategoryPath(getValue(map, PATH)));
chnode.setSelected((getValue(map, SELECTED).equalsIgnoreCase("true")) ? true : false);
if (getValue(map, EXPANDED).equalsIgnoreCase("true")) ;
tree.expandPath(model.getTreePathToRoot(chnode));
}
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void execute() {
if (MediatorGui.treeDatabase() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.treeDatabase() in "+ this.getClass());
}
// Tree model, update the tree (refresh, add node, etc)
DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGui.treeDatabase().getModel();
// First node in tree
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
// Loop into the list of databases
for (Database database: this.databases) {
// Create a node model with the database element
AbstractNodeModel newTreeNodeModel = new NodeModelDatabase(database);
// Create the node
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(newTreeNodeModel);
// Save the node
MediatorGui.frame().getTreeNodeModels().put(database, newNode);
// Add the node to the tree
root.add(newNode);
}
// Refresh the tree
treeModel.reload(root);
// Open the root node
MediatorGui.treeDatabase().expandPath(new TreePath(root.getPath()));
MediatorGui.treeDatabase().setRootVisible(false);
}
代码示例来源:origin: ron190/jsql-injection
MediatorGui.treeDatabase().expandPath(new TreePath(tableNode.getPath()));
代码示例来源:origin: ron190/jsql-injection
MediatorGui.treeDatabase().expandPath(new TreePath(databaseNode.getPath()));
代码示例来源:origin: jshiell/checkstyle-idea
/**
* Expand the given tree to the given level, starting from the given node
* and path.
*
* @param tree The tree to be expanded
* @param node The node to start from
* @param path The path to start from
* @param level The number of levels to expand to
*/
private static void expandNode(final JTree tree,
final TreeNode node,
final TreePath path,
final int level) {
if (level <= 0) {
return;
}
tree.expandPath(path);
for (int i = 0; i < node.getChildCount(); ++i) {
final TreeNode childNode = node.getChildAt(i);
expandNode(tree, childNode, path.pathByAddingChild(childNode), level - 1);
}
}
代码示例来源:origin: com.google.code.findbugs/findbugs
@Override
public void run() {
try {
System.out.println("auto expanding " + p);
tree.expandPath(p);
} catch (Exception e) {
e.printStackTrace();
}
}
});
代码示例来源:origin: igvteam/igv
private void expandPath(TreePath treePath) {
if (!tree.isExpanded(treePath)) {
tree.expandPath(treePath);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
/** Expand the given path and makes it visible.
* @param path the path
*/
protected void showPath(TreePath path) {
tree.expandPath(path);
showPathWithoutExpansion(path);
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
@Override
public void run() {
LOG.log(Level.FINEST, "Just print the variable so it is not GCed: {0}", prepare);
final TreePath p = getTreePath(n);
LOG.log(Level.FINE, "expandNode: {0} {1}", new Object[] { n, p });
tree.expandPath(p);
LOG.fine("expandPath done");
}
});
代码示例来源:origin: igniterealtime/Spark
/**
* Call to expand the entire tree.
*/
public void expandTree() {
for (int i = 0; i <= tree.getRowCount(); i++) {
tree.expandPath(tree.getPathForRow(i));
}
}
代码示例来源:origin: kaikramer/keystore-explorer
private void expandTree(JTree tree, TreePath parent) {
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.getChildCount() >= 0) {
for (Enumeration<?> children = node.children(); children.hasMoreElements();) {
TreeNode subNode = (TreeNode) children.nextElement();
TreePath path = parent.pathByAddingChild(subNode);
expandTree(tree, path);
}
}
tree.expandPath(parent);
}
代码示例来源:origin: kaikramer/keystore-explorer
private void expandTree(JTree tree, TreePath parent) {
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.getChildCount() >= 0) {
for (Enumeration<?> enumNodes = node.children(); enumNodes.hasMoreElements();) {
TreeNode subNode = (TreeNode) enumNodes.nextElement();
TreePath path = parent.pathByAddingChild(subNode);
expandTree(tree, path);
}
}
tree.expandPath(parent);
}
代码示例来源:origin: apache/felix
public void runDiscovery(){
Gateway[] g = Gateway.newGateways(bc);
for (int i = 0 ; i < g.length ; i++) {
this.createTreeNode(g[i]);
}
(new Thread(this.pt)).start();
tree.expandPath(new TreePath(((DefaultMutableTreeNode)(dtm.getRoot())).getPath())); // expand root node
}
内容来源于网络,如有侵权,请联系作者删除!