How to get the root node of a tree?

I wanna get all the leaf node of a tree.But JTree have no method about how to get the root TreeNode of a tree.Then how should I do?

try this:
http://javaalmanac.com/egs/javax.swing.tree/GetNodes.html?l=rel

Similar Messages

  • How to get the root node for a child using connect by prior

    Hi,
    I searched at many places to do this but not able to get the exact o/p sp posting my question here.
    I have a table with parent_id and child_id columns. The levels of this parent_child can be many but my aim is to find the ultimate parent ( dont know the right term)
    like if I have a child_node= xyz and its parent= pqr and its parents=lmn which might be ultimate parent which doesnt have any further parent.
    So if i start with child_code= "xyz" then i should get the parent as "lmn" and not the immediate parent "pqr".
    Please help.
    Thanks,
    Aashish

    To find the Parent on emp table:
    select empno,ename,level
    from emp
    where level=3
    start with empno=7934
    connect by  empno= prior mgrTo find the Child on emp table:
    select empno,ename,level
    from emp
    where level=1
    start with empno=7934
    connect by prior empno=  mgrBut you need to know the level or position to specify the level of parent or child. But there are some other possible options available if we can know the requirement properly.
    Edited by: Vasista on Jan 11, 2011 2:27 AM
    Edited by: Vasista on Jan 11, 2011 2:30 AM

  • How to get the current node element by its value?

    e.g,:
    wdContext.current<b>Deal</b>Element().setAttributeValue("<i>deal_id</i>","<i>aaaaaaa</i>");
    above code can get the result i wanna.
    but now i wanna in terms of its node'name to  set attribute vaue of itself. in other words,i have no idea about how to get the current node element by its name"<b>Deal</b>".

    Hi Wing,
    The answer is there in your question itself.
    wdContext.currentDealElement()
    will give you the current node element by its name"Deal" or you could use
    wdContext.nodeDeal().getCurrentElement()
    or you could use
    wdContext.nodeDeal().getElementAt(wdContext.nodeDeal().getLeadSelection())
    Regards,
    Sudeep

  • How to get the Change node in Production Server!!!!!

    Hi Guys,
    Kindly let me know how to get the Change node in Production Server for the Transaction Code Pe03 for generating the Acknowledgement No for the year 2008 .
    Plz provide me the steps how to get the Change Node for Acknowledgement No so tat i can get the configuration done.
    Regards
    Ansuman Mohanty.

    Hi Mr!
    If you want to generate the e-file feature 40ACK, do it in our Customization client box (Golden box) & save the request & move to Quality & production.
    Still if you need to workout only in Production, than with the help of Basis people you can get the Production change mode for 5 to 10 min time & can generate it. But mostly Basis people wont give us change mode for Production box ... with ur request they can do..try it.
    Did u collected 4 quarter TAN no's for 2008 Quarter...if not collect it & generate it at a time.
    All the best:-)
    Kind Regards,
    Saisree.S

  • How to get the root view of a UIView?

    How to get the root view of a UIView?

    Hi, loop through the superview property until it's nil. I suggest implenting it as a category:
    @implementation UIView (whatever)
    - (UIView *)rootView;
    @end
    - (UIView *)rootView
    UIView *rootView = self;
    while (rootView.superview) rootView = rootView.superview;
    return rootView;
    Warning: typed from memory, so not guaranteed to be errorfree.

  • Setting background color to just the root node in a tree

    How can I set a background color to just the root node in a tree? I got the node in the followig way in the renderer method.
    IconNodeClass parentIconNode = (IconNodeClass)((IconNodeClass)value).getRoot();
    Then how can I set the background for just the root node? Thanks.

    You need to write ur own treeCellRenderer for that to be done

  • How to get the selected node value of a tree which is build on java code

    Hi Experts,
    How can i get the selected node value if I build the tree programatically.
    I am using the following code in selectionListener but it is throwing error.
    RichTreeTable treeTable = (RichTreeTable)getQaReasontreeTable();
    CollectionModel _tableModel =
    (CollectionModel)treeTable.getValue();
    RowKeySet _selectedRowData = treeTable.getSelectedRowKeys();
    Iterator rksIterator = _selectedRowData.iterator();
    String selectedQaCode ="";
    while (rksIterator.hasNext()) {
    List key = (List)rksIterator.next();
    JUCtrlHierBinding treeTableBinding =
    (JUCtrlHierBinding)((CollectionModel)treeTable.getValue()).getWrappedData();
    JUCtrlHierNodeBinding nodeBinding =
    treeTableBinding.findNodeByKeyPath(key);
    String nodeStuctureDefname =
    nodeBinding.getHierTypeBinding().getStructureDefName();
    selectedQaCode = selectedQaCode + nodeBinding.getAttribute(0);
    where I am using following link to create a tree with java code.
    http://one-size-doesnt-fit-all.blogspot.com/2007/05/back-to-programming-programmatic-adf.html
    Please help me in resolving this issue.
    Regards
    Gayaz

    Hi,
    you should also move
    JUCtrlHierBinding treeTableBinding =
    (JUCtrlHierBinding)((CollectionModel)treeTable.getValue()).getWrappedData();
    out of the while loop as this is not necessary to be repeated for each key in the set
    Frank

  • How to get the parent node of the current node?

    Hi all,
    i want to get the parent node of the current node and the not the parent of the parent node.
    thank you very much

    Hi,
    the parent node of <subnode1-2>29.99</subnode1-2> is (node1), how can do to get <node1> throw <subnode1-2>29.99</subnode1-2> the sub node of <node1>.
    As per my understanding the parent node of <subnode1-2>29.99</subnode1-2> is book not the node1.
    If you want node 1 as a parent of subnode1-2 than your xml will look like this.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <bookstore>
    <book>
    <fathernode>Harry Potter</fathernode>
    <node1>
           <subnode1>29.99</subnode1>
           <subnode2>29.99</subnode2>
    </node1>
    <node2>
           <subnode1>19.99</subnode1>
           <subnode2>19.99</subnode2>
    </node2>
    </book>
    </bookstore>
    and also if you want tom retrive float data than refer following XPATH.
    "//book[[price='1000']]/price/text()"
    Regards,
    Manoj Bilthare

  • How to get the leaf node in a hierachy????

    if i get a record that a parent node in a hierachy table ,so how can i get the leaf node of this parent node quicklly?????thank you!

    Hi xuhuanjun ,
    Refer to the below threads which disucss the same.
    Re: how to ensure a hierarchy tree's node is a internal leaf???????
    Re: Retrieve Hierarchy Leaf Node using API.
    Hope it helps.
    Thanks,
    Minaz

  • How to get the root class in call heirarchy

    Hi,
    Is anybody have some idea regarding the getting name of a class whose, main method was called at the time of begining. In other words if we say, how can we get the invoker class of a java program with multiple level of inheritence.
    Regards

    DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder db=factory.newDocumentBuilder();
         Document doc=db.parse(new File(ur xml file"));
         Element root=doc.getDocumentElement();
         System.out.println("root "+root.getNodeName());

  • How to get the children for a selected tree node?

    Hi,
    I want to get the number of child nodes for any selected node in JTree.
    How can i do this?
    Any help, greatly appreciated!!

    if you have a node already where aNode is a DefaultMutableTreeNode for example, then you can use that object's API method to get the child count.
    int childCount = aNode.getChildCount();
    If you want to loop through all of a node's children and do something at each node, the following may help:
    java.util.Enumeration e = aNode.children();
    while ( e.hasMoreElements() ) {
    DefaultMutableTreeNode n = (DefaultMutableTreeNode)e.nextElement();
    //Do something with n
    Hope this helps,
    Claire

  • How to get the root tag name

    I have a problem: I receive several XML files in my transaction input
    <?xml version="1.0" encoding="UTF-8"?>
    <NAMES>
    </NAMES>
    <?xml version="1.0" encoding="UTF-8"?>
    <VALUES>
    </VALUES>
    and I want to obtain the root tag name (the string NAMES, VALUES, ecc.).
    I obtained this result using a XSL transformation, bui I think that the best (and easiest) way is to use an XPath command. I tried but I can not find the right command.
    Does anybody know how to do this?

    I found it:
    Transaction.Source{name(/*)}

  • How to get the root directory of a domain?

    I have a domain setup at
    C:\bea\user_projects\domains\myDomain
    I have tried the following;
    Getting the domain object : get attr DomainConfiguration from DomainRuntimeServiceMBean
    Get root dir : get attr RootDirectory from domain object
    It returns ".", but I need the full path.
    Is there an issue with the RootDirectory from domain object or in my approach?

    John,
    OK. If you want to go the JMX route, have a look at the CurrentDirectory attribute of the ServerRuntime mbean. It would report your directory as this:
    C:\bea\user_projects\domains\myDomain\.
    Mike
    Weblogic/J2EE Security Blog: http://monduke.com

  • How to create multiple root node in a tree

    Hi Experts,
    As per my requirement I have two requirements for  tree creation:
    1) Create a Tree which can display multiple root node.
    2) Cretae a Tree which can display data directy without any folder.
    I am new in Tree development.
    Can any body help me out to get it done.
    If it is not possible then also i need a confirmation from experts.
    Regards,
    Madhu

    use method add_node of the class Cl_gui_alv_tree to add a node to the tree.
    In case of root node the parameter lv_relat_key is passed as blank.In order to create further child nodes pass the node key of the parent as the relat key of the child and use the method again.
    Regards,
    Abhi

  • How we know the selected node in a Tree object in a form?

    In a TREE object in forms, how can we know the current selected node by clicking a push button.
    lets say , there are 10 nodes in my tree, and 5th one i selected. But i want to store the selected node in a variable, when i click a button.
    please help
    thanks

    Hello
    I've just notice what might be a bug in Oracle forms because when I have the when-tree-node-selected trigger present for the tree (It does not matter if it executes null or some code), the code in option 1 works fine on a when-button-pressed trigger on a button item. This is what I had done to give you a reply.
    My second option will work because you're populating a parameter with when-tree-node-selected trigger which is then readable form anywhere else in the form. All you add is a check on when-button-pressed. Also for bug handling you need to consider setting the value to null when deselecting. I have this option working currently in one of my applications.
    DECLARE
         num_selected NUMBER;
         htree ITEM;
    curren_node FTREE.NODE;
    BEGIN
    htree := find_item('tree.form_list');
    num_selected := ftree.get_tree_property(htree,ftree.selection_count);
    for j in 1..num_selected
    LOOP
    curren_node := ftree.get_tree_selection(htree,j);
    message('hello :'||ftree.Get_Tree_Node_Property(htree,curren_node,ftree.node_value),acknowledge);
    end loop;
    END;     
    cheers
    Q

Maybe you are looking for