Can Tree's folder icon node changed to different icon?

Hi,
Currently, the tree and tree table node's icon is a "folder" icon. Can this be customized to different icons? We would like to have different icons for the nodes for different level in the tree/tree table. For example, level 1's node is icon A; level 2's node is icon B, etc...
Any suggestions?
Thanks.
-Mina

Hi,
I think the right way of doingthis indeed is skinning. I would try to
- set a styleClass value to the styleClass property using EL against a managed bean method.
- The managed bean method now is called for each node. Use EL in the managed bea method to access the #{node} EL to determine the row you are on
- set the style class to e.g. level1, level2, level3
- Then in the skinning you use
level1 af|tree...{}
level2 af|tree...{}
To define the different icons for the tree levels. Note that using DAF all icons are using folders. So there is no sense in skinning leaf icons
Frank

Similar Messages

  • Icon was changed to default icon when editting a node on JTree

    I have a tree with icon on nodes. However, when I edit the node, the icon is changed to default icon.
    I don't known how to write the treeCellEditor to fix that one.
    The following is my code:
    package description.ui;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    import javax.swing.ToolTipManager;
    import javax.swing.WindowConstants;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellEditor;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreePath;
    import javax.swing.tree.TreeSelectionModel;
    public class Tree extends javax.swing.JPanel {
         private JTree tree;
         private JScrollPane jScrollPane1;
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              frame.getContentPane().add(new Tree());
              frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              frame.pack();
              frame.show();
         public Tree() {
              super();
              initGUI();
         private void initGUI() {
              try {
                   BorderLayout thisLayout = new BorderLayout();
                   this.setLayout(thisLayout);
                   setPreferredSize(new Dimension(400, 300));
                    jScrollPane1 = new JScrollPane();
                    this.add(jScrollPane1, BorderLayout.CENTER);
                        DefaultMutableTreeNode rootNode = createNode();
                        tree = new JTree(rootNode);
                        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
                        jScrollPane1.setViewportView(tree);
                        ToolTipManager.sharedInstance().registerComponent(tree);
                        MyCellRenderer cellRenderer = new MyCellRenderer();
                        tree.setCellRenderer(cellRenderer);
                        tree.setEditable(true);
                        tree.setCellEditor(new DefaultTreeCellEditor(tree, cellRenderer));
                        //tree.setCellEditor(new MyCellEditor(tree, cellRenderer));
              } catch (Exception e) {
                   e.printStackTrace();
         private void btRemoveActionPerformed(ActionEvent evt) {
             TreePath path = tree.getSelectionPath();
             DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
             ((DefaultTreeModel)tree.getModel()).removeNodeFromParent(selectedNode);
         private DefaultMutableTreeNode createNode() {
             DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Doc");
             DefaultMutableTreeNode ch1 = createChuongNode(rootNode, "Ch1");
             DefaultMutableTreeNode ch2 = createChuongNode(rootNode, "Ch2");
             createTextLeafNode(ch1, "title");
             return rootNode;
         private DefaultMutableTreeNode createChuongNode(DefaultMutableTreeNode parent, String name) {
             DefaultMutableTreeNode node = new DefaultMutableTreeNode(new ChapterNodeData(name));
             parent.add(node);
             return node;
         private DefaultMutableTreeNode createTextLeafNode(DefaultMutableTreeNode parent, String name) {
             DefaultMutableTreeNode node = new DefaultMutableTreeNode(new TitleNodeData(name));
             parent.add(node);
             return node;
          private class MyCellRenderer extends DefaultTreeCellRenderer {
                 ImageIcon titleIcon;
                 ImageIcon chapterIcon;
                 public MyCellRenderer() {
                     titleIcon = new ImageIcon(getClass().getClassLoader()
                            .getResource("description/ui/icons/Text16.gif"));
                     chapterIcon = new ImageIcon(getClass().getClassLoader()
                            .getResource("description/ui/icons/Element16.gif"));
                 public Component getTreeCellRendererComponent(
                                     JTree tree,
                                     Object value,
                                     boolean sel,
                                     boolean expanded,
                                     boolean leaf,
                                     int row,
                                     boolean hasFocus) {
                     super.getTreeCellRendererComponent(
                                     tree, value, sel,
                                     expanded, leaf, row,
                                     hasFocus);
                     if (isChapterNode(value)) {
                         setIcon(chapterIcon);
                         setToolTipText("chapter");
                     } else if (isTextLeafNode(value)) {
                         setIcon(titleIcon);
                         setToolTipText("title");
                     return this;
                 protected boolean isChapterNode(Object node) {
                     return ((DefaultMutableTreeNode)node).getUserObject() instanceof ChapterNodeData;
                 protected boolean isTextLeafNode(Object node) {
                     return ((DefaultMutableTreeNode)node).getUserObject() instanceof TitleNodeData;
          private class MyCellEditor extends DefaultTreeCellEditor {
                 ImageIcon titleIcon;
                 ImageIcon chapterIcon;
              public MyCellEditor(JTree tree, DefaultTreeCellRenderer renderer) {
                  super(tree, renderer);
                  titleIcon = new ImageIcon(getClass().getClassLoader()
                         .getResource("description/ui/icons/Text16.gif"));
                  titleIcon = new ImageIcon(getClass().getClassLoader()
                         .getResource("description/ui/icons/Element16.gif"));
              public Component getTreeCellEditorComponent(
                           JTree tree,
                           Object value,
                           boolean isSelected,
                           boolean expanded,
                           boolean leaf,
                           int row) {
                  super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
                  return this.editingComponent;
          abstract class NodeData{
              String name;
              public NodeData(String name) {
                  this.name = name;
              public String getName() {
                  return name;
              public void setName(String name) {
                  this.name = name;
              public String toString() {
                  return name;
          class ChapterNodeData extends NodeData {
              public ChapterNodeData(String s) {
                  super(s);
          class TitleNodeData extends NodeData {
              public TitleNodeData(String attr) {
                  super(attr);
    }

    Arungeeth wrote:
    I know the name of the node... but i cant able to find that nodeHere is some sample code for searching and selecting a node:
        TreeModel model = jtemp.getModel();
        if (model != null) {
            Object root = model.getRoot();
            search(model, root, "Peter");//search for the name 'Peter'
            System.out.println(jtemp.getSelectionPath().getLastPathComponent());
        } else {
            System.out.println("Tree is empty.");
    private void search(TreeModel model, Object o, String argSearch) {
        int cc;
        cc = model.getChildCount(o);
        for (int i = 0; i < cc; i++) {
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) model.getChild(o, i);
            if (model.isLeaf(child)) {
                TreeNode[] ar = child.getPath();
                String currentValue = Arrays.toString(ar);
                if (currentValue.contains(argSearch)) {
                    jtemp.setSelectionPath(new TreePath(ar));
            } else {
                search(model, child, argSearch);
    }

  • Icon have changed to preview icons

    Hi.I use PEAK as an audio editor which uses its own file icon.Just recently all my normal peak icons suddenly changed in to what I guess must be Preview icons,the ones with the semi-quaver,a bit like itunes. Also every time I save something in peak the original peak icon changes. I have set the files to open in peak in the get info but it still makes no difference. Any ideas why and how can I stop this! Thanks,Tony

    Ok, this is happening every time I launch Photoshop, the Layer Panel options "Show thumbnails" box is turned off by default, and I have to go in and turn it on again each time.
    I recall recently that an AppleCare support tech, in an effort to fix some Mac Mail issues, had me throw away a folder in the Library, maybe Prefs?, and restart. This is the only thing I've done to my system in recent memory. No upgrades, no new apps, nothing else i can come up with...
    Would really like to resolve this! Any ideas? thanks

  • Where can I found table or structure changes across different releases ?

    Hi !
    Just one question:
    I would like to found where can I see tables or structures changes across differents releases of SAP R/3?, i tried to found a doc about this... but i couldn't found it.
    For example, which table have been modify form version 4.x to 4.z, i mean fields added or modified, etc...
    Thanks in advance,
    Albio.-

    Hi Albio,
    You can do this. You can check the activation log of any table which you have to find for change history.
    Just go to se11 and type the table name click on display and then go to utilities -> then activation log, it will show you all the changes made to table
    Regards
    Sumit Bhutani
    <b>Ps reward pts if helpful</b>

  • Icon's change to Adobe icons

    Adobe sucks. It needs to warn us, before we download to install Adobe Reader, that installing the software will corrupt our desktop icons and make them into useless Adobe icons.  What a greedy damned company, they must all be Republicans!

    that installing the software will corrupt our desktop icons and make them into useless Adobe icons.
    Before you go getting all upset over what sounds like a simple case of operating system file associations:
    Which operating system?
    What specifically happens? Do the icons for PDF files change to Adobe icons or is something else happening?
    Any chance of a screenshot?

  • Most of my desktop icons have changed to itunes icons....

    Most of my desktop icons and all of my quick taskbar icons changed to itunes icons after upgrading to 10.4.....
    I uninstalled itunes and reinstalled using version 9 and the problem has returned.
    For now I've removed all itunes software and my computer seems to be OK.
    Is there a fix for this????

    Hi,
    This might be caused by service conflict, I suggest to perform a clean boot in this way:
    1.Swipe in from the right edge of the screen, and then tap Search. Or, if you are using a mouse, point to the lower-right corner of the screen, and then click Search.
    2.Type msconfig in the search box, and then tap or click msconfig.
    3.On the Services tab of the System Configuration dialog box, tap or click to select the Hide all Microsoft services check box, and then tap or click Disable all.
    4.On the Startup tab of the System Configuration dialog box, tap or click Open Task Manager.
    5.On the Startup tab in Task Manager, for each startup item, select the item and then click Disable.
    6.Close Task Manager.
    7.On the Startup tab of the System Configuration dialog box, tap or click OK, and then restart the computer.
    Details as below:
    http://support.microsoft.com/kb/929135
    Regards
    Wade Liu
    TechNet Community Support

  • Creative Cloud Problem - Try Icons not changing to Download Icons

    I just purchased a Creative Could for Teams membership and my icons will not change from "Try" to "Download". I've installed the Adobe Application Manager and I've also logged out and logged back in several times and the icons still do not change. Can someone help?

    Hi David... thank you for your offer of help. Have come round to that view ourselves that the issue was possibly caused right at the start of our purchase. That's now 10 days gone by without access to the products and we are starting to wonder if it will ever be resolved.
    Incidentally could I ask? Is it the case that the software should be available simply by logging on with your ID and password to creative.adobe.com and then selecting "Apps"? When we log onto creative.adobe.com and click on "My Account" it only shows 2GB space available instead of 20GB and on the Plan Information tab it shows the "Free membership" option when we would presume it should show our purchase of Creative Cloud. We have checked with our bank and the payment for the CC subscription did process with the first payment made to Adobe on the date of purchase.
    The software presently installed on the workstation is Adobe Master Suite CS6 and is a high end spec HP Z800 (windows 7 pro service pack 1) if that helps in anyway. The Adobe Download Manager was installed previously as part of an update for our CS6 Master Suite package.
    If you can fix this for us you are on our Christmas card list lol.....
    Thanks
    Bill

  • Why have my homepage bookmark icons now changed to firefox icons

    am running samsung tab2 and homepage icons became firefox icons overnight...cannot edit text cannot remove firefox logo even after reloading original bookmarks . where did they go.?

    Hey lezli today a had this experience, but after i restart the cellphone the icons back to normal..

  • Wrong Icon Appears & Copy/Pastes Different Icon

    Kind of a strange problem.
    I've had my Blackbook for a couple of months, and all of a sudden today I noticed that a file I created using TextEdit had changed its icon to that of the application PhotoBooth. "Weird" think I, so I attempt to change it back by opening a text file somewhere else on my computer and copying its icon in 'Get Info' and then pasting it into the 'Get Info' of the text file with the weird PhotoBooth icon - except it pastes the wrong icon. Now I have the little house icon that is the same as the user. ***? There doesn't seem to be a way to revert back to the original icon, and now every subsequent text file I create has the little house icon.
    I'm wondering if maybe the graphic set for the icons has been corrupted or messed up. How can I get them back to normal? Anyone else experienced this problem?

    Kind of a strange problem.
    I've had my Blackbook for a couple of months, and all
    of a sudden today I noticed that a file I created
    using TextEdit had changed its icon to that of the
    application PhotoBooth. "Weird" think I, so I
    attempt to change it back by opening a text file
    somewhere else on my computer and copying its icon in
    'Get Info' and then pasting it into the 'Get Info' of
    the text file with the weird PhotoBooth icon - except
    it pastes the wrong icon. Now I have the little
    house icon that is the same as the user. ***? There
    doesn't seem to be a way to revert back to the
    original icon, and now every subsequent text file I
    create has the little house icon.
    I'm wondering if maybe the graphic set for the icons
    has been corrupted or messed up. How can I get them
    back to normal? Anyone else experienced this problem?
    Have you tried deleting the image while in "Get Info?" This has always reverted the image to the original default icon image for me.

  • How to set different Icons for Jtreenode

    How to set different Icons for Jtreenode,i want to set icons for jtreenode,not only for leaf,open,closeicon,i hope that each node has a different icon.Thanks!

    you need to check for the node value within a renderer, then assign an icon based on what you expect to get back.
    check out this page. http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html

  • How can i change the default icon of a new folder?

    what i mean is like every time i create a new folder instead of changing the icon after its created, can i somehow change the default icon on a new folder i create? so when i create a new folder its created with the icon i want it to have?
    and i want to do it manually i dont want to use programs for it
    thanks

    nemesio wrote:
    i know but i dont want to use candy bar, were do i go to do it manually?
    why not? use LiteIcon then. it's free and is MUCH safer than mucking with system files by hand. if you insist you can do it as follows. go to /system/library/coreservices. control-click on coretypes.bundle and select "show package contents". go to contents-> resources. change the file GenericFolderIcon.icns with your own .icns file. back up the original bundle first.

  • How do I change desktop folder/safari pictures to registered business icons, I have tried almost every how to  on-line but none are worki?  I have treing. First how do I get the icon I need from the website and then what?

    How do I change Mac desktop folder/safari pictures to registered business icons? I have tried almost everythin but none are working.  First how do I capture the business icon from the website, then what?

    OK, well to start with, you must have the icon file in the correct format. You need to end up with an .icns file. One of the how-to articles should tell you how to do this - iConvert will also do it.
    If it is in the correct format, when you click the icon file to highlight it, and click cmd-i, you will see the Get Info window - at the top left, you should see a mini version of the icon. If you do NOT see that icon correctly, the file is not the correct format. So this will not work for a jpg or png file, for example.
    Once you have this window open, go to the thumbnail, click it to highlight it blue, and click cmd-C to copy.
    Go to your Safari app from the Applications folder (not from the dock), again click cmd-i to open its Get Info window, and again click its icon to highlight it blue. Now click cmd-V to paste. You will be asked for your admin password to authenticate. The icon should now become the one you've pasted in.
    You may need to log out and back in for the effect to show on the application file itself.
    You might also want to look into Candybar if you plan on doing a lot of icon customization.
    Matt

  • Icon of a node changes when I edit its content

    I have a JTree that represent an xml document.
    and I have a TreeCellRenderer that sets the Icon of the node according to its type:
    public class XmlTreeCellRenderer extends DefaultTreeCellRenderer {
          * Overrides this method to display the apropriate icon according
          * to the type of the <code>Node</code>.
         @Override
         @SuppressWarnings("hiding")
         public Component getTreeCellRendererComponent(
                   JTree tree, Object value, boolean sel,
                   boolean expanded, boolean leaf, int row, boolean hasFocus) {
              super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
                        row, hasFocus);
              if (!(value instanceof XmlTreeNode)) {
                   return this;
              // retrieves the type of the node
              XmlTreeNode treeNode = (XmlTreeNode) value;
              short nodeType = treeNode.getNodeType();
              // sets the icon of the node and the foreground color
              // according to the type
              switch (nodeType) {
              case Node.ELEMENT_NODE:
                   setForeground(Color.BLACK);
                   setIcon(ELEMENT_ICON);
                   break;
              case Node.TEXT_NODE:
                   setForeground(Color.BLUE);
                   setIcon(TEXT_ICON);               
                   break;
              case Node.COMMENT_NODE:
                   setForeground(Color.GREEN);
                   setIcon(COMMENT_ICON);               
                   break;
              default:
                   setToolTipText("This is an unknown node");
                   break;
              return this;
         // the image resources
         private static final ImageIcon TEXT_ICON =
              new ImageIcon("resource/images/TextIcon.jpg");
         private static final ImageIcon COMMENT_ICON =
              new ImageIcon("resource/images/CommentIcon.jpg");
         private static final ImageIcon ELEMENT_ICON =
              new ImageIcon("resource/images/ElementIcon.jpg");
    }Now the problem is when I edit a node's content the icon changes back
    to the default icon, like this.
    This is before I edit the node's content:
    http://img140.imageshack.us/my.php?image=before6zj.jpg
    This is after:
    http://img89.imageshack.us/my.php?image=after2xd.jpg
    Notice how the "E" changed to the folder icon.
    How do I disable it?
    I want it to stay with the "E" icon even when I edit the node's content.
    I tried in the XmlTreeCellRenderer to use setClosedIcon and setOpenIcon
    but it didn't work.

    I have a JTree that represent an xml document.
    and I have a TreeCellRenderer that sets the Icon of
    the node according to its type:<snip>
    Now the problem is when I edit a node's content the
    icon changes backIt's a bug. See:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4663832

  • How can I change a user icon position?

    How can I change the position that Yosemite determines for where a user icon is positioned on the login screen? I'm the admin and I added a standard user and the icon placement for that user is first, I'm second, and Guest User is third...it does not appear to be alphabetical. I'd like to switch the first two so my user icon is the first one on the left.

    Locate a folder icon you wish to use. Select it and press COMMAND-C to copy. Select the folder you want changed. Press COMMAND-I to open the Get Info window. At the top left you will see that folder's icon. Click on it then press COMMAND-V to paste.
    If you want to create your own icons then you will need an application to do that. For example, Folder Icon Changer 3.0.7.
    Google searches will locste tons of pre-made folder icons you csn use. Some are free and some are not.

  • Firefox 31 changes all PDF icons to Firefox HTML icons that I can not seem to change back, can this be rectified? Using Windows XP.....

    Once Firefox 31 is installed it sees all PDF files as Firefox HTML files and changes all of the PDF icons to Firefox HTML icons. This change can not seem to be reversed without uninstalling Firefox.
    Only the icon is changed, not the .PDF extension.

    Thank you for your reply but it's not that simple:
    Windows now thinks that the default file type for .pdf is Firfox HTML Document.
    I can change which program opens .pdf files but I can't change the icon.
    Not a Firefox problem? Really?
    EDIT:
    Let me explain further so that you can understand. In folder options / file types I can scroll thru and choose any file type / advanced and change the icon...every one of them except (now) .pdf. There is no advanced tab. Only the message about "restore" I mentioned before.
    Firefox changed the file association for .pdf files and now I can't fix it.
    And from another thread:
    "Firefox 31 is not converting or renaming your files. All it is doing is registering with the Windows OS as an application that is able to open the files and Windows then changes the file's icons accordingly.
    This should only occur if no other application has already registered your .pdf files."
    Well I guess that's not true is it?

Maybe you are looking for

  • Is it possible to use digital signature in Sales order of SAP B1 ?

    Hi Experts, Version: 8.81 PL07 Cyrstal report Layout: 2011 Is it possible to use digital signature in Sales order of SAP B1 ? Thanks in advance, Regards, Dwarak

  • Change the x-axis series in excel chart

    Hi,     While plotting an Excel chart using ExcelRpt_ChartWizard(), the x - axis series starts from 0, 1, 2, 3... I like to change the series according to the data present in a particular column. Eg. If column 2 contains 2, 5, 7, 6.2... then the x-ax

  • Mobile me album file names lost

    I have used iPhoto to add two albums to my mobile me gallery and in the process have lost a lot of the file names. I am displaying the photos online so people can choose which ones they would like to order so really need the names/numbers. Is there a

  • Non-cummulative KF wih NCum value change

    hi, Could anyone tell me the difference between the types of non-cummulative keyfigures Non-cummulative value wih ncum value change & Non-cummulative value with in and out flow Kindly give me an example for the first one, I am pretty ok with the infl

  • Unity Data Store for unity 8

    Guys,   Im installing unity 8.0.3  , but unfortunately stuck at " cisco data store" .When i searched google itsays to install "sql server 2005 sp3" or"sql server express 2005 sp3". I installed express , but unity assistant still shows the result as "