How do i expand all the nodes in a jtree

Hi,
I am working on a project where i need to expand all the nodes of a jtree i have tried a few different ways but it never seems to expand all the nodes..
I would be very greatful if someone could point me in the right direction
cheers
Mary

you could use the following method that expands nodes recursively
expandNode( myTree, myRootNode, new TreePath( myRootNode ) );
public static void expandNode( JTree tree, TreeNode node, TreePath path ) {
    tree.expandPath( path );
    int i = node.getChildCount( );
    for ( int j = 0; j< i; j++ ) {
        TreeNode child = node.getChildAt( j );
        expandNode( tree, child , path.pathByAddingChild( child ) );
}

Similar Messages

  • How to expand all the nodes in a tree while loading the tree initially

    Hi All
    Now i am able to display the tree strucute in webdynpro.
    but it is displaying the tree initially in collapsed mode until/unless we click on the node root it will be expanded.
    but my requirement is i wanted to display the tree in expanded mode by default at runtime initially.
    can you please provide any setting to be done or any sample code on the same then it would be great help to me.??
    Thanks
    Trisha

    Hi,
    isLeaf is an attribute you need to create under "CatalogEntries" node. And "isRoot" is not requried.
    Download the sample project "TutWD_TreeByNestingTableColumn". See the below link to dnld this project.
    https://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/503f22f6-b978-2a10-bf97-ddc21267e752 [original link is broken]
    Do the changes in sample project as below:
    Invoke this method in the init method as below (as it is in the same project).
    addCatalogEntries(wdContext.nodeCatalogEntries(), "ROOT");
    Change the code in addCatalogEntries() method as below.
    Here we are calling the addCatalogEntries() method recursively for all the parent elements and we are changing the  setExpanded property to true.
    public void addCatalogEntries( com.sap.tut.wd.treetable.wdp.IPrivateTreeTableView.ICatalogEntriesNode node, java.lang.String parentId )
    //@@begin addCatalogEntries()
    IPrivateTreeTableView.ICatalogEntriesElement newCatalogEntriesElement;
    for (int i = 0; i < Catalog.getLength(); i++) {
    if (parentId.equals(Catalog.getParentId(i))) {
    // create new context node element
    newCatalogEntriesElement = node.createCatalogEntriesElement();
    node.addElement(newCatalogEntriesElement);
    // provide node elements with data
    newCatalogEntriesElement.setID(Catalog.getCATALOGID(i));
    newCatalogEntriesElement.setTITLE(Catalog.getTITLE(i));
    newCatalogEntriesElement.setDESCRIPTION(Catalog.getDESCRIPTION(i));
    newCatalogEntriesElement.setAMOUNT(Catalog.getAMOUNT(i));
    if ("ARTICLE".equals(Catalog.getCATALOGTYPE(i))) {
    // checkbox is visible by default
    newCatalogEntriesElement.setPUBLISHED(Catalog.getPUBLISHED(i));
    // third level is last level
    newCatalogEntriesElement.setIsLeaf(true);
    } else {
    // a CATEGORY does not use the checkbox column
    newCatalogEntriesElement.setUsageOfPublishedAttribute(WDVisibility.BLANK);
    newCatalogEntriesElement.setIsLeaf(false);
    newCatalogEntriesElement.setChildrenLoaded(true);
    newCatalogEntriesElement.setExpanded(true);
    addCatalogEntries(newCatalogEntriesElement.nodeChildCatalogEntries(),newCatalogEntriesElement.getID());

  • How to disable "Expand All" and "Collapse All" when no node in a tree

    I have a <af:tree> inside <af:panelCollection>.
    All items under viewMenu like "Expand", "Expand All Below", "Collapse All Below", "Expand All" , "Collapse All", "Scroll to First" and "Scroll to Last" are implemented by default.
    When there is no node in a tree, "Expand", "Expand All Below", and "Collapse All Below" are grey out.
    However, "Expand All" , "Collapse All", "Scroll to First" and "Scroll to Last" are still enabled to be clicked.
    Is there any way we can diable them when no node?

    When I highlight last node in the tree and all nodes are collapsed, I see "Expand All Below" enabled but "Collapse All Below" disabled. Which is expected. Expand All Below will expand all the child nodes under a node.
    QA filed a bug said that "Expand All Below" should be disabled since no node below it. However, I don't find any place to control them. Can you confirm this? Or you know some way to do this?It it not a bug then. You don't have to control it and framework takes care of enabling and disabling it accordingly.
    If you need to expand all the nodes programatically, check this out.
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/78-man-expanding-trees-treetables-354775.pdf
    -Arun

  • Sorting the nodes of a JTree

    Can anyone tell me how to go about sorting the nodes in a JTree?

    The best way to do it is thru the treemodel. Either adjust the order in a DefaultTreeModel, or create your own TreeModel.

  • How can I list all the domains configured for Weblogic Servers?

    How can I list all the domains configured for Weblogic Servers?
    I saw a note, which says the following:
    "WebLogic Server does not support multi-domain interaction using either the Administration Console, the weblogic.Admin utility, or WebLogic Ant tasks. This restriction does not, however, explicitly preclude a user written Java application from accessing multiple domains simultaneously."
    In my case, I just want to list all the domains, is that possible by using any scripts?
    Thanks
    AJ

    If you use WLS Node Manager and the Config Wizard was used to create the domains, then the list of domains should be in a location like this:
    <MIDDLEWARE_HOME>\wlserver_10.3\common\nodemanager\nodemanager.domains
    Enterprise Manager Grid Control also has support for multi-domain management of WLS in a console.

  • To display all the Nodes in a Binary Search Trees

    Hi,
    I want to traverse through all the nodes in a binary tree. I know that there are traversals like Preorder,Postorder,Inorder. But I am not able to write a recursive code for performing this operation. Can anyone please help me or give me an idea how to write a code to do any one of these traversal.
    Thanks a lot in advance.

    Hi,
    hmm .. how is a tree-node defined? - As so you have not posted a node-class, I will help you by demonstrating it for inOrder by normal language:
    The Idea is as follows:
    You have a root, that references to a tree-node. This tree-node has a value and 2 references to other tree-nodes, let's say they are named left and right. Because left an right are references to tree-nodes in the same way root is a reference to the tree-node, this fact can be used for recursive action on the tree.
    if you like to display all values in the tree, what do you have to do in a node?
    1. display the tree the left reference is pointing to
    2. display the value-Field
    3. display the tree the right reference is pointing to
    that is inOrder, assuming all lesser values are in the left tree and all greater are in the right tree.
    How to display the left and right trees?
    The same way you display this node, but this time you use the left / right reference as the node.
    So do it in pseudo-coding:
    void DisplayTree(NodeClass aNode) {
    if (aNode == null) return;
    DisplayTree(aNode.left);
    DisplayValue(aNode.value);
    DisplayTree(aNode.right);
    That is it - figure it out and try to write a program after this - good luck. To write one for pre-order and post-order should be easy if you have this one for inOrder.
    greetings Marsian

  • How can i print all the contect of the code in sapscript window ? ?

    how can i print all the contect of the code in sapscript window ? ?

    Hi,
    Do you mean that you want to print the ABAP code to SAPscrip form ?
    Svetlin

  • How can i print all the tab pages not just the first page (tab)

    how can i print all the tab pages not just the first page (tab)

    You would need to do this programmatically. Here's one way:
    Attachments:
    Example_VI_BD6.png ‏3 KB

  • I am running out of memory on my hard drive and need to delete files. How can I see all the files/applications on my hard drive so I can see what is taking up a lot of room?

    I am running out of memory on my hard drive and need to delete files. How can I see all the files/applications on my hard drive so I can see what is taking up a lot of room?
    Thanks!
    David

    Either of these should help.
    http://grandperspectiv.sourceforge.net/
    http://www.whatsizemac.com/
    Or search 'disk size' in the App Store.
    Be carefull with what you delete & have a backup BEFORE you start, you may also want to reboot to try to free any memory that may have been written to disk.

  • How do I find all the purchased items on my iPhone? When I try to update the iPhone iOS while connected to my MacBook it says there are purchased items on the phone that have not been transferred to my iTunes library and that I should transfer them.

    How do I find all the purchased items on my iPhone? When I try to update the iPhone iOS while connected to my MacBook it says there are purchased items on the phone that have not been transferred to my iTunes library and that I should transfer them before updating.

    Thanks. This seems to have worked easily.

  • When creating a book how can I get all the photos from an album to show up in the order they were in the album?

    When creating a book in iphoto, how can I get all the photos from the album I want to use to show up in the order that they are in the album?  When I tried to use the option to add my own photos instead of having the program "flow" them, they showed up all mixed up.

    iPhoto puts them in the book in chronological order.  So to get your photos from an album into an iPhoto book in the same order you will need to use the Photos ➙ Batch Change ➙ Date menu option and set them all to the same date with a 1 minute time difference between each. 
    OT

  • The display on my MacBook Pro from 2007 finally gave out, how do I transfer all the data from the old one onto my new one?

    A week or so ago, the screen on the Macbook Pro I've had for 5 years went permanently black. The screen itself still works, but it's just all black. Went from flickering/flashing to black. I didn't have any kind of warranty on it or anything, and in addition to all of the other things about it that needed fixing, it seemed like it'd just be cheaper to get a new Macbook Pro.
    My question is: How do I get all the stuff from the old laptop to the new laptop without having to use the old laptop's display? Is there a cable I can use to connect the two, and I can just access the old one from the new one?

    FireWire between the two (get appropriate 800-800 or 400-800), Target Disk Mode on the old one, appears as an external disk on the new one. Drag everything over, or use Setup Assistant if first start of new one, or plain old Migration Assistant. You really don't need a display to see a prancing FireWire icon, do you?
    http://support.apple.com/kb/HT1661
    http://support.apple.com/kb/HT4889
    (with the added advantage that since you ain't booting anything off the drive, can turn the Mac on or off at will without risking data corruption on the drive)

  • How do I get all the accounts on my mac to have access to the same itunes library?

    How do I get all the accounts on my mac to have access to the same itunes library?

    Move the entire iTunes folder to: Macintosh HD > Users > Shared.
    Hold the option key when launching iTunes (for each user).
    Click Choose Library.
    Navigate to Macintosh HD > Users > Shared > iTunes.
    Open the iTunes Library.itl file.

  • TS4124 Hi, do you know how can I upload inelegible songs from itunes to Icloud. They are songs added from original CDs. Another question would be how can I transfer all the music I have in my Ipod Classic to my Itunes or ICloud as I want to back it up.

    Hi, do you know how can I upload inelegible songs from itunes to Icloud. They are songs added from original CDs. Another question would be how can I transfer all the music I have in my Ipod Classic to my Itunes or ICloud as I want to back it up.

    Depends on why it's ineligible.  If it's under 96 Kpbs, try right-clicking on the file and choosing Create AAC Version.  (If you don't see this option, go to iTunes>Preferences, click "Import Settings..." then choose "Import Using: AAC Encoder" and "Setting: iTunes Plus".)  Then rescan your library to see if this version will add to iTunes Match.  Or, after changing your import setting, just re-import the song to your iTunes library.
    If the song is over 200 MB you would have to reduce it's size to make it eligible.

  • How can i display all the query items to a table?

    how can i display all the query items to a table in a jsp file?
    i always have an out of memory error..

    any body??any idea?
    is it possible thru configuration or i have to write a program by the abaper??
    Biswa

Maybe you are looking for

  • Touchscreen and Other Frustrations

    I am a commercial truck driver that owns an iPhone 4S. The only available means of keeping the phone charged is by utilizing the vehicle's 12 volt DC plug (also known as the cigarette lighter plug for most). Whenever I try to use the phone while it's

  • Control the use of material code

    Hi there, which field of the DB table MARA (or whichever) controls the use of material as sales code and manufacturing code - DISST? Like STLAN of the structue RC29N. The request is to list all material codes with its "flag" to build a list of 2 colu

  • Truncate, then reload causes ora-00001 unique constraint on apply side

    I setup schema level replication using the maintain_schema procedure. Its replicating DML and not DDL. I have a source side process that truncates a table then reloads it every day. Since DDL is not replicating, the reload produces generates an ora-0

  • Action which saves incremental versions of the current file name.

    I have several folders of PNG files I want to hue to differnt colours and then save a version in each colour. I sucessfuly recorded an action that makes the hue adjustments and saves files, the problem I'm having is the action uses the name and locat

  • Load automatically in a Cube (Bi 7.0)

    Hi, I have a push mechanisms which put data in a DataSource... how can I load automatically data to the ODS and Infocube which are connected... I mean DataSource-->ODS-->Cube I am working in Version BW 7.0 Thanks FedeX