You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Enrico Spinielli <En...@marconi.com> on 2001/08/07 10:23:54 UTC
how to traverse Category tree in order to build a JTree
Hi all,
I would like to know how you can traverse the log4j category tree.
My goal is to build (at runtime) a JTree that represents the available
Categories
and allow the user to change Priority, Appender ...
I thoght I could use something like the following:
Category cr = Category.getRoot();
// build a JTree representing the current Log4J category tree
// and start from root category
// for any other category ask for its parent and add the new node
// to the parent node
DefaultMutableTreeNode r = new DefaultMutableTreeNode(cr);
DefaultMutableTreeNode n;
Category c;
for (Enumeration en = c.getCurrentCategories(); cs.hasMoreElements(); )
{
c = (Category)cs.nextElement();
// create a (DefaultMutable)TreeNode
n = new DefaultMutableTreeNode(c);
// find parent Category
c.getParent(); //!!!!!!!!!!!!!!!!!!!!!!!!!! HOW ?????
// find (DefaultMutable)TreeNode of parent Category
// ??? my find here
// and add the corresponding (DefaultMutable)TreeNode
parentNode.add(n);
}
JTree tree = new JTree(r);
//...
But I cannot find how to retrieve the parent Category...
Any suggestions is welcome
Enrico
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org