Change behaviour of Expand/collapse icon in JTree

Want to change the behaviour of Expand/collapse icon in a JTree. Need help with the same. Thanks.

Check: Hide and show region

Similar Messages

  • How do I remove expand / collapse icon for JTree empty folders

    Hi
    I am using a JTree as a file system browser. I use DefaultMutableTreeNode nodes.
    I have a problem with empty folders.
    Empty folders show the expand / collapse icon, leading the user to believe there are sub-directories. When the user double-clicks the folder, the expand / collapse icon goes away. This is a "haha-gotcha" glitch that I really don't want my users to have to continually deal with.
    So, how might I get my JTree to not show the expand / collapse icon for empty folders?
    Thanks
    Wayne

    Maybe I can use the FileSystemView isTraversable(File f) method in my TreeCellRenderer class to check if anything is in the directory.
    But I still need to know how to disable the expand / collapse icon for such a node.

  • JTree without expand/collapse icons

    I want to be able to hide or change the expand/collapse icon of a specific node, not the entire Jtree.
    Is there any way to do that?
    Tahnx

    I want to be able to hide or change the expand/collapse icon of a specific node, not the entire Jtree.
    Is there any way to do that?
    Tahnx

  • Remove/hide expand/collapse icons

    Hi,
    I would like to remove/hide the expand/collapse icons and have a fixed navigation iView.
    Thanks in advance.
    Rgds,
    Janvi

    Hi Janvi,
    Probably to hide the collapse and expand icon you could go about with the theme editor , where u can set the url to these images as some blank image that coincides with ur background colour.
    To have a fixed navigation panel without scrolling ,probably you can change the the width of the navigation panel by changing the value defaultExpWidth in the file WAandNAVPanel.js file in the par file com.sap.layouts.framework.par from 220 pixels to a higher value.Later u need to upload the file back and restart ur system.
    Hope this helps,
    Regards,
    Uma.

  • How do I remove the "TOC" btn in the playbar WITHOUT removing the TOC "Expand/Collapse" icon?

    I am working in CP7 on a project with a Table of Contents that is set to 'Overlay'. The client has requested that I remove the "TOC" button in the playbar, without removing the TOC "Expand/Collapse" icon, so that the user can still hide/reveal the TOC when necessary. The only control I can find is the "Show TOC" checkbox under Project > Table of Contents. However, un-checking this option removes both the "TOC" button AND the "Expand/Collapse" icons. Is it possible to remove just the "TOC" button in the playbar?

    If you are using SWF output you can always edit the playbar in Flash and remove it.
    If HTML5 you can edit the JavaScript out put to remove the button from the playbar.

  • Show 'Expand'/'Collapse' Icon in Tray

    Hi All,
              I have done the following configuration in the portal and the result is confusing, can you please help me understand why?
    1. I have created 2 pages, first is a standard portal page and second a webdynpro page in a test folder
    2. copied a standard SAP iView to the test folder and added it to both the pages as a delta link
    3. opened the iview property from the std. page and set the "Show u2018Expandu2019/u2019Collapseu2019 Icon in Tray" property to NO
    4. opened the iview property from the webdynpro page and set the "Show u2018Expandu2019/u2019Collapseu2019 Icon in Tray" property to NO
    When i preview the standard page the iView appears without the "Expand/Collapse" icon, but when i preview the webdynpro page the iview appears with the "Expand/Collapse" icon.
    Thanks,
    Anand

    Hi Raghu,
                   Our portal version is 7.01 SPS15.
    Hi All,
             Any suggestions?
    Edited by: Kirupanand Venkatapathi on Oct 4, 2010 11:32 AM

  • TreeByNesting image changes required for Expand,Collapse and Leaf Icons

    Hi
    I am currently working on webdynpro for Java on NW04s SP15.
    I have embedded Tree Element inside Table. I need to change the Expand,Collapse and Leaf Arrows inside Table. I dont find those things inside Theme Editor.
    Could you please suggest how can I change those Icons.
    Thank you
    Regards
    Krishna Kanth.

    Hi WalterLaan,
    Thanks for your replay, I had tried with TreeExpansionListener before posting it, but not with TreeWillExpandListener.
    I have a mouseListener to handle a leaf on single click.
    My problem is now my foldernode has arrowIcon, folder icon, text, all three respond for click action(expand/collapse), since my renderer has all the three in one panel and rendering it
    but i want arrowIcon has to behave separate on single click and folder icon and text has to behave different at the same time.
    I have plan to separate it(arrowIcon in one panel/ another two in another panel) in a renderer, is it will help me?
    Thanks, your post given little light to me.
    I will do more R&D of this.
    More suggestion are welcome.

  • How to hide Expand/ Collapse icon from ADF Query Panel.

    Hi Experts,
    I need to hide the expand collapse button from the ADF Query panel.
    is there any way to hide it.
    Please help me.
    Thanks in Advance.
    Balaji,

    Hi Balaji,
    Create a CSS file and the below code
    af|query.CustomQueryPanel::disclosure-icon-container { background-image: url("../img/minus.png"); display:none; height:0px; width:0px; }
    af|query.CustomQueryPanel::disclosed-icon { display:none; }
    af|query.CustomQueryPanel::undisclosed-icon { display:none; }
    Add styleClass="CustomQueryPanel" inside <af:query...>
    Now you can try...:)
    Thanks
    Prabhat

  • Detailed Navigation (disable expand./collapse icons opening tree

    Hi,
    I would like to adjust the detailed navigation as this site performs with having no action when clicking the +/- icons.
    Please can someone point me in the right direction.  I have been able to get the detailed navigation.par file out and look at the jsp code, but not sure where this requires a change.
    Will reward points for a helpful answer....
    Kai

    If I am reading your question correctly, you want to create a detailed navigation similar to SDN so that when you click on the expand/collapse icon it doesn't do a server round trip.
    Firstly I believe that the standard one performs a round trip to retrieve the nodes underneath the one that you have expanded.
    With SDN we created our own detailed navigation iview so that the entire navigation structure is loaded immediately. This is also the same if you use the standard light navigation iview I believe, so you could simply use this iview instead.
    I hope this helps
    Darrell

  • Expand/Collapse a block in a selection screen

    Hey Folks,
    I have a requirement , where I have a selection screen, with 3 selection blocks. I have a requirement that I need to make 2 of these blocks expandible/collapsible on the toggle of a button.. How can this be achieved.
    In case of a normal screen, I would have had to create the blocks as subscreens (one type of screen for expanded state...another for collapsed state) and called it from the main screen. But how do I achieve the same using the selection screens?
    I was considering creating the blocks as subscreens in the selection screen and calling them in the PBO of the main selection screen. However, I am unsure if thats a wise thing to do since the screen is generated automatically in case of a selection screen and I do believe its not a good idea to manually alter it.
    Does anyone has any pointers on this?
    Thanks and Best Regards,
    Puja.

    Hi,
    I have modified the code to show the expand/collapse ICON accordingly..Please check..
    TABLES sscrfields.
    TYPE-POOLS icon.
    * Expand/collapse buttons.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN PUSHBUTTON 2(23)  b1 USER-COMMAND usr1.
    SELECTION-SCREEN END OF LINE.
    * Block 1
    SELECTION-SCREEN BEGIN OF BLOCK b1.
    PARAMETERS: p_test1 TYPE char10  MODIF ID m1,
                p_test2 TYPE char10  MODIF ID m1.
    SELECT-OPTIONS  s_date  FOR sy-datum MODIF ID m1.
    SELECTION-SCREEN END OF BLOCK b1.
    * Block 2
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN PUSHBUTTON 2(23)  b2 USER-COMMAND usr2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF BLOCK b2.
    PARAMETERS: p_test3 TYPE char10  MODIF ID m2,
                p_test4 TYPE char10  MODIF ID m2.
    SELECTION-SCREEN END OF BLOCK b2.
    * Declarations
    DATA: v_flag, v_flag1.
    INITIALIZATION.
      b1 = 'Button1'.
      b2 = 'Button2'.
      v_flag = 'X'.
      v_flag1 = 'X'.
    AT SELECTION-SCREEN.
    * Check the user command.
      IF sy-ucomm = 'USR1'.
        IF v_flag IS INITIAL.
          v_flag = 'X'.
        ELSE.
          CLEAR v_flag.
        ENDIF.
      ELSEIF sy-ucomm = 'USR2'.
        IF v_flag1 IS INITIAL.
          v_flag1 = 'X'.
        ELSE.
          CLEAR v_flag1.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN OUTPUT.
      IF v_flag1 = 'X'.
        CALL FUNCTION 'ICON_CREATE'
          EXPORTING
            name   = icon_expand
            text   = 'Button 2'
            info   = 'Button 2'
          IMPORTING
            RESULT = b2
          EXCEPTIONS
            OTHERS = 0.
      ELSEIF v_flag1 IS INITIAL.
        CALL FUNCTION 'ICON_CREATE'
          EXPORTING
            name   = icon_collapse
            text   = 'Button 2'
            info   = 'Button 2'
          IMPORTING
            RESULT = b2
          EXCEPTIONS
            OTHERS = 0.
      ENDIF.
      IF v_flag = 'X'.
        CALL FUNCTION 'ICON_CREATE'
          EXPORTING
            name   = icon_expand
            text   = 'Button 1'
            info   = 'Button 1'
          IMPORTING
            RESULT = b1
          EXCEPTIONS
            OTHERS = 0.
      ELSEIF v_flag IS INITIAL.
        CALL FUNCTION 'ICON_CREATE'
          EXPORTING
            name   = icon_collapse
            text   = 'Button 1'
            info   = 'Button 1'
          IMPORTING
            RESULT = b1
          EXCEPTIONS
            OTHERS = 0.
      ENDIF.
      LOOP AT SCREEN.
    * Expand collapse block1
        IF v_flag = 'X' AND screen-group1 = 'M1'.
          screen-active = 0.
        ELSEIF v_flag IS INITIAL AND screen-group1 = 'M1'.
          screen-active = 1.
        ENDIF.
    * Expand collapse block2
        IF v_flag1 = 'X' AND screen-group1 = 'M2'.
          screen-active = 0.
        ELSEIF v_flag1 IS INITIAL AND screen-group1 = 'M2'.
          screen-active = 1.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    Thanks
    Naren

  • Expand/Collapse option in Portal - SP13

    Hi everybody!!
    We have EP7.0 NetWeaver 2004s and we upgraded the SP from 5 to 13.  When SP13 was installed, the icon to expand/collapse doesn't work correctly (Detail Navigation in Navigation Panel in the Light Framework).  The icon always send the user to the main and first page.  With the SP5 it works well.
    Do you have any idea about how can I solve this??
    Thanks in advance for any help that you can give me!
    Best Regards,
    Claudia

    Hi Claudia,
    Take a look at this thread maybe it gives you some answers...
    How to disable automatic loading of iView/Page in detailed navigation?
    We have SP13 at this moment and its working "fine":
    1. When clicking on the expand/collapse icon (the triangle) the first navigation node in this folder/workset is NOT loaded automatically.
    2. When clicking on the text part of the link (the actual url) the first navigation node in this folder/workset IS loaded.
    In addition to step 2 you can steer what navigation node is loaded by setting the parameter "Default Entry for Folder" this property is by default set to No.
    Also take a look at the property: "Clicking Folder Name Launches First Node" of the Detailed Navigation iView.. Maybe this is by some reason got set properly...
    Good Luck,
    Benjamin Houttuin

  • Expand/Collapse function in WAD 7.0

    Hi,
    I have made a report in WAD using a table and a chart. In the output which I am running on a portal I have a table Report Navigation with  in which I have some of the export options and an Expand / Collapse icons are present on the button group and also I have one drop down box calendar year .As soon as I click on the icon Collapse in  the above table Report Navigation my drop down should get collapsed and again when I click on the Expand the drop down should be visible
    Report naviagtion and  Drop down boxes are present in a seperate table where in when I click on the icons( Expand / Collapse ) it should get reflected on the dropdown box which is present on the 2nd table
    I have done the above in WAD 3.5 using Java script Code
    How can this be done in WAD 7.0
    Regards,
    Maya

    Hi,
    After setting the Analysis item properties, just click on the 7th icon on top menu bar, i think its Verify or Check on server. Somthing like that.
    Or try re-opening the template after sometime. Close the existing Web window, where you see your output, and execute the template once again. This should work.
    If nothing of the above works, theres one more thing. You may have to re-create the Template.
    This happens at times when there is no proper connection between the Portal and WAD. I have faced it myself. So, just try something like that.

  • Expand/Collapse query structure?

    Hi all,
    I'm working with a structure in a BW query. In this BW query you have the possibility to expand or collapse structure nodes. Is it possible to overwrite this property in Design Studio?
    I tried to use the scripting formula DS_1.collapseNode("technical ID structure", "technical ID member structure") but it doesn't work.
    Any ideas?
    Thanks, Vanessa

    Hi Vanessa,
    I had the same case on my project(not a real hierarchy, but a structure).
    I've implemented it using a button - I have an image of a + and a -  that collapses and expands the hierarchy.
    try to do it with a button or and image (in the onClick event). and if it works, you can call this event from startup or in background processing.
    about your second answer, in design studio:
    go to your datasource ->right click->edit initial view
    there you will see the query exactly as you defined it in bex.
    change the hierarchy expand\collapse state, and click ok.
    the data in the crosstab will change accordingly.
    hope it helps,
    Roman

  • TP4 FileExplorer tree: change Folder icon when expanded/collapsed

    I am trying to create a tree similar with FileExplorer from the Demo application. I am trying to use two icons for every node: one for expanded node and another one for collapsed.
    I use a rowDisclosureListener tag
    rowDisclosureListener="#{menuBean.menuRowDisclosureEvent}to fire an expand/collapse event. In a custom method menuRowDisclosureEvent(RowDisclosureEvent disclosureEvent) I retreive the selected node and programatically change the icon. The only thing is that the tree view itself is not refreshed on the same phase cycle. The node icons are refreshed only at the next requests.
    Thanks,
    /Florin

    I have also tried to use:
    AdfFacesContext.getCurrentInstance().addPartialTarget(tree);Didn't helped

  • JTree with XML content expand/collapse problem

    Hello all,
    I'm having this very weird problem with a JTree I use to display the contents of an XML file. I use the DOM parser (and not JDOM since I want the application to run as an applet as well, and don't want to have any external libraries for the user to download) and have a custom TreeModel and TreeNode implementations to wrap the DOM nodes so that they are displayed by the JTree.
    I have also added a popup menu in the tree, for the user to be able to expand/collapse all nodes under the selected one (i.e. a recursive method).
    When expandAll is run, everything works fine and the children of the selected node are expanded (and their children and so on).
    However, after the expansion when I run the collapseAll function, even though the selected node collapses, when I re-expand it (manually not by expandAll) all of it's children are still fully open! Even if I collapse sub-elements of the node manually and then collapse this node and re-expand it, it "forgets" the state of it's children and shows them fully expanded.
    In other words once I use expandAll no matter what I do, the children of this node will be expanded (once I close it and re-open it).
    Also after running expandAll the behaviour(!) of the expanded nodes change: i have tree.setToggleClickCount(1); but on the expanded nodes I need to double-click to collapse them.
    I believe the problem is related to my implementations of TreeModel and TreeNode but after many-many hours of trying to figure out what's happening I'm desperate... Please help!
    Here's my code:
    public class XMLTreeNode implements TreeNode 
         //This class wraps a DOM node
        org.w3c.dom.Node domNode;
        protected boolean allowChildren;
        protected Vector children;
        //compressed view (#text).
         private static boolean compress = true;   
        // An array of names for DOM node-types
        // (Array indexes = nodeType() values.)
        static final String[] typeName = {
            "none",
            "Element",
            "Attr",
            "Text",
            "CDATA",
            "EntityRef",
            "Entity",
            "ProcInstr",
            "Comment",
            "Document",
            "DocType",
            "DocFragment",
            "Notation",
        static final int ELEMENT_TYPE =   1;
        static final int ATTR_TYPE =      2;
        static final int TEXT_TYPE =      3;
        static final int CDATA_TYPE =     4;
        static final int ENTITYREF_TYPE = 5;
        static final int ENTITY_TYPE =    6;
        static final int PROCINSTR_TYPE = 7;
        static final int COMMENT_TYPE =   8;
        static final int DOCUMENT_TYPE =  9;
        static final int DOCTYPE_TYPE =  10;
        static final int DOCFRAG_TYPE =  11;
        static final int NOTATION_TYPE = 12;
        // The list of elements to display in the tree
       static String[] treeElementNames = {
            "node",
      // Construct an Adapter node from a DOM node
      public XMLTreeNode(org.w3c.dom.Node node) {
        domNode = node;
      public String toString(){
           if (domNode.hasAttributes()){
                return domNode.getAttributes().getNamedItem("label").getNodeValue();
           }else return domNode.getNodeName();      
      public boolean isLeaf(){ 
           return (this.getChildCount()==0);
      boolean treeElement(String elementName) {
          for (int i=0; i<treeElementNames.length; i++) {
            if ( elementName.equals(treeElementNames)) return true;
    return false;
    public int getChildCount() {
         if (!compress) {   
    return domNode.getChildNodes().getLength();
    int count = 0;
    for (int i=0; i<domNode.getChildNodes().getLength(); i++) {
    org.w3c.dom.Node node = domNode.getChildNodes().item(i);
    if (node.getNodeType() == ELEMENT_TYPE
    && treeElement( node.getNodeName() ))
    // Note:
    // Have to check for proper type.
    // The DOCTYPE element also has the right name
    ++count;
    return count;
    public boolean getAllowsChildren() {
         // TODO Auto-generated method stub
         return true;
    public Enumeration children() {
         // TODO Auto-generated method stub
         return null;
    public TreeNode getParent() {
         // TODO Auto-generated method stub
         return null;
    public TreeNode getChildAt(int searchIndex) {
    org.w3c.dom.Node node =
    domNode.getChildNodes().item(searchIndex);
    if (compress) {
    // Return Nth displayable node
    int elementNodeIndex = 0;
    for (int i=0; i<domNode.getChildNodes().getLength(); i++) {
    node = domNode.getChildNodes().item(i);
    if (node.getNodeType() == ELEMENT_TYPE
    && treeElement( node.getNodeName() )
    && elementNodeIndex++ == searchIndex) {
    break;
    return new XMLTreeNode(node);
    public int getIndex(TreeNode tnode) {
         if (tnode== null) {
              throw new IllegalArgumentException("argument is null");
         XMLTreeNode child=(XMLTreeNode)tnode;
         int count = getChildCount();
         for (int i=0; i<count; i++) {
              XMLTreeNode n = (XMLTreeNode)this.getChildAt(i);
              if (child.domNode == n.domNode) return i;
         return -1; // Should never get here.
    public class XMLTreeModel2 extends DefaultTreeModel
         private Vector listenerList = new Vector();
         * This adapter converts the current Document (a DOM) into
         * a JTree model.
         private Document document;
         public XMLTreeModel2 (Document doc){
              super(new XMLTreeNode(doc));
              this.document=doc;
         public Object getRoot() {
              //System.err.println("Returning root: " +document);
              return new XMLTreeNode(document);
         public boolean isLeaf(Object aNode) {
              return ((XMLTreeNode)aNode).isLeaf();
         public int getChildCount(Object parent) {
              XMLTreeNode node = (XMLTreeNode) parent;
    return node.getChildCount();
         public Object getChild(Object parent, int index) {
    XMLTreeNode node = (XMLTreeNode) parent;
    return node.getChildAt(index);
         public int getIndexOfChild(Object parent, Object child) {
    if (parent==null || child==null )
         return -1;
              XMLTreeNode node = (XMLTreeNode) parent;
    return node.getIndex((XMLTreeNode) child);
         public void valueForPathChanged(TreePath path, Object newValue) {
    // Null. no changes
         public void addTreeModelListener(TreeModelListener listener) {
              if ( listener != null
    && ! listenerList.contains( listener ) ) {
    listenerList.addElement( listener );
         public void removeTreeModelListener(TreeModelListener listener) {
              if ( listener != null ) {
    listenerList.removeElement( listener );
         public void fireTreeNodesChanged( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener =
    (TreeModelListener) listeners.nextElement();
    listener.treeNodesChanged( e );
         public void fireTreeNodesInserted( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener =
    (TreeModelListener) listeners.nextElement();
    listener.treeNodesInserted( e );
         public void fireTreeNodesRemoved( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener =
    (TreeModelListener) listeners.nextElement();
    listener.treeNodesRemoved( e );
         public void fireTreeStructureChanged( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener =
    (TreeModelListener) listeners.nextElement();
    listener.treeStructureChanged( e );
    The collapseAll, expandAll code (even though I m pretty sure that's not the problem since they work fine on a normal JTree):
        private void collapseAll(TreePath tp){
             if (tp==null) return;
             Object node=tp.getLastPathComponent();
             TreeModel model=tree.getModel();
             if (!model.isLeaf(node)){
                  tree.collapsePath(tp);
                  for (int i=0;i<model.getChildCount(node);i++){
                  //for (int i = node.childCount()-4;i>=0;i--){
                       collapseAll(tp.pathByAddingChild(model.getChild(node,i)));
                  tree.collapsePath(tp);
        private void expandAll(TreePath tp){
             if (tp==null) return;
             Object node=tp.getLastPathComponent();
             TreeModel model=tree.getModel();
             if (!model.isLeaf(node)){
                  tree.expandPath(tp);
                  for (int i=0;i<model.getChildCount(node);i++){
                  //for (int i = node.childCount()-4;i>=0;i--){
                       expandAll(tp.pathByAddingChild(model.getChild(node,i)));

    Hi,
    Iam not facing this problem. To CollapseAll, I do a tree.getModel().reload() which causes all nodes to get collapsed and remain so even if I reopen them manually.
    Hope this helps.
    cheers,
    vidyut

Maybe you are looking for

  • Need help connecting to internet wirelessly

    Please help. I just had Comcast high-speed Internet installed in my home yesterday. I opted for their free d-link modem and wireless router promotion. When I connect the modem directly to my g4 ibook, I have Internet access. However, I'm having troub

  • Focus on the editor Tab which is already opened (vspackage)

    I am binding  list of items to the toolwindow from database,when i click the item, corresponding item name editor tab opens but  when i click the same item i want to Focus(Active) the same editor tab.It should not open the new tab.I am using followin

  • LR4 - Hierarchical Keyword Metadata Writing Problem

    Having found a problem with LR4 in reading hierarchical metadata from photo files, I now seem to have found a similar problem when writing metadata to files. As before, I use hierarchical keywords with the "/" character as the separator in the photo

  • Bbm not work in Q 10

    Attn all urgent services for BBM not work msg is unable to connect to BBM no data services in my country Saudi Arabia all services provider and wifi not work from last day Please need you're action to fixed and problem only in device Q 10 Thanks

  • Driver won't install for USB 2.0 controller in Thunderbolt chassis

    I have a Thunderbolt to PCIe chassis attached to my MacBook Air. It has three PCIe slots available. Two of those slots are populated with USB 3.0 cards and these are working correctly. The third slot has a USB 2.0 card installed. This card does not w