JTree Update Leaf Icon

Hi,
I have two problem with Jtree.
1.How can I put different Icons for different leafs of the same node?
2.How is it possible to refresh or update the Jtree(by adding or removing some leaf) that the leaf Icons remain?
Thanks for your help.

1.How can I put different Icons for different leafs of the same node?Yes, ... either write a custom cell renderer or find a "merged icon".. there are examples of both around the forums.
2.How is it possible to refresh or update the Jtree(by adding or removing
some leaf) that the leaf Icons remain?No. if you remove a node, the node is gone. If you don't remove the node, the node stays. IF you want to leave the leaf icon, you can have a renderer which just displays the icon and not the text.

Similar Messages

  • Individual leaf icons in JTree

    is it possible to for different leaves in the same tree to have different icons?
    I tried this code:
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Actors");
            File dir = new File("images\\actors\\");
            int i = 0;
            DefaultMutableTreeNode actorChild;
            String[] fileArray = dir.list();
            while (i < dir.listFiles().length){
                ImageIcon icon = new ImageIcon(getClass().getResource("images\\actors\\" + fileArray));
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    renderer.setLeafIcon(icon);
    actorChild = new DefaultMutableTreeNode(fileArray[i]);
    root.add(actorChild);
    i++;
    actorTree.setCellRenderer(renderer);
    DefaultTreeModel t = new DefaultTreeModel(root);
    actorTree.setModel(t);
    However as you can see it merely sets all leaf icons to the last  value from the last iteration of the loop.
    any info appreciated :)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    This is my latest attempt, but it still doesnt work, it just makes the icon for the last item in the jtree.
    I cant figure out what im doing wrong here, any ideas?
    class CustomIconRenderer  extends JLabel implements TreeCellRenderer {
        String[] fileArray;
        CustomIconRenderer(String[] fileArray){
            this.fileArray = fileArray;
        public Component getTreeCellRendererComponent(JTree tree,
                Object value, boolean sel, boolean expanded, boolean leaf,
                int row, boolean hasFocus) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            Object obj = node.getUserObject();
            String nodeName = obj.toString();
            setText(nodeName);  // set the text
            int i = 0;
            while (i < fileArray.length){
              if (nodeName.endsWith(fileArray)){
    Icon icon = new ImageIcon(getClass().getResource("images\\actors\\"+ nodeName));
    setIcon(icon);
    else{
    setIcon(null);
    i++;
    return this;

  • How to change leaf icon in jtree

    Hi,
    I have one treeviewer class in which i have set the leaf icon like
    renderer1.setLeafIcon(new ImageIcon(RMViewer.getApplication().getIconImageManager().getImage("TRMA")));
    it's working fine..i have one more class namely IntFrame....there i have one button which display some doc...now when i click on button i wanna change only selected leaf icon not other leaf icon...
    how do i proceed...can u provide me some examples
    regards
    Tarique

    Can u provide me the some source code...
    i m not able to do this..
    Regards
    Tarique

  • How to remove folder and leaf icons from a tree

    Hi,
    I know how to remove when we have a mx component i.e.,
    <mx:Tree folderOpenIcon={null} ...../> similarly for
    closed and default leaf icon.
    But how do i achieve this from an action script like say i
    have,
    var tree:Tree = new Tree();
    tree.setFolderOpenIcon(null); ///is there something like this
    or any other alternative.
    Please advice.
    Thanks,
    Lucky

    the folderOpenIcon is a style so you have to set it with the
    setStyle method
    try:
    tree.setStyle("folderOpenIcon",null);

  • Apps icon shows updates when i go there the update all icon is not highlighted if you go to any of the UPDATE box's you are directed to the application????

    apps icon shows updates when i go there the update all icon is not highlighted if you go to any of the UPDATE box's you are directed to the application????

    ATtempt to power off your device and power it back on, if that doesn't work reset all settings should resolve it for you

  • HT1338 how do I update my icon on my Mac desktop?

    How do I update my icon on my Mac Desktop?

    I can only surmise you are running 10.6.6 or later, since the Mac App Store became available then.  Go to Apple menu -> About This Mac and tell us your Mac OS X version.    Some Mac OS X versions could have their icons changed, while others could not.   I can get a moderator to move this thread to the correct forum once I know your version and know whether or not I can answer this question.

  • Can't update vault - icon is pale red

    For some reason I can't seem to be able to update my vault. The drive is connected and appears in the vault pane, but the update vaults icon is a pale red. Update All Vaults in the File menu is also grayed out. There is over 200GB available on the drive, I don't get any error messages, and I can create a new vault on the same drive. I just can't update any of them.
    I searched here for answers, but couldn't find anything. So if any one has any advice please let me know.
    Thanks,
    Andrew

    Hi,
    had the same problem and fixed it like this:
    In Preferences remove ..aperture.plist
    Log out as the current user
    Log in as a different user (maybe you´d have to create one)
    Start Aperture
    Close Aperture
    Log out
    Log in as "yourself"
    Start Aperture
    Use ShiftR to show Vaults
    Now it should work again as usual, worked for me, that is
    Greetings from Munich, Germany

  • SW update notification icon not showing.

    hi, i have nokia N8 running symbian belle refresh. Automatic updates are set to on, and there is update to application also availlable but its not showing the update notification icon.
    I have another nokia n8 in which nokia belle came preinsatalled and that is showing update notification....dnt got it why....

    Thanks for the reply. Unfortunately, when I viewed this pane it was unchecked.
    II'll keep searching.
    Steve.

  • Loaded updated no icons on desktop and windows load offscreen ***

    Loaded updated no icons on desktop and windows load offscreen ***

    Nobody has any thoughts or has had the same issue on this one? Any thoughts are greatly appreciated!
    Thank you!

  • FrameMaker update book icon not updating and custom formatting help

    Hi,
    I am fairly new to FrameMaker, and I am currently experiencing two issues:
    First Issue
    I am currently trying to create a book that currently has three chapters. I am trying to break it out into the following format:
    Main TOC - includes all the headers and related pages for the entire book
    Mini TOC - includes a mini TOC that highlights all the headers and pages associated with Chapter Source File A
    Chapter Source File A - includes all related content to Chapter Source File A
    Mini TOC - includes a mini TOC that highlights all the headers and pages associated with Chapter Source File B
    Chapter Source File B - includes all related content to Chapter Source File B
    Mini TOC - includes a mini TOC that highlights all the headers and pages associated with Chapter Source File C
    Chapter Source File C - includes all related content to Chapter Source File C
    Whenever I click the Update Book icon, however, it does not update the headers and page numbers. They still remain the same way when I first generated them. This occurs for both the main TOC and mini TOC.
    Second Issue
    In addition to the format structure I designed for my book, I also wanted to create a custom format look that remains constant whenever I update my TOC. I have tried testing this, but I noticed every time I generate a new TOC it is always in the unformatted FrameMaker style which you have reformat each time.
    Is there a way to create a custom format look that can retain the design and simply update the TOC headers and page numbers each time it needs to be updated?
    Any help is greatly appreciated
    Thank you!

    First I'd highly recommend getting Matt Sullivan's Publishing Fundamentals: Unstructured FM11 book - it's a pretty complete reference one to have on FM.
    Second, it sounds like you may not have your ToC reference pages set up correctly - if nothing changes when you've added content that should have created more ToC headings and shift pages around, then something is amiss. Your formatting problem is solved by doing a bit of a dodge - you create a ToC and generate it, then replace it with your formatted .fm doc keeping the exact name as the generated doc; then update again. Now the content is formatted the way you want and keeps being updated each time you update.

  • Tree.leafIcon for leafIcon.  How about non-leaf Icon?

    Tree.leafIcon for leafIcon. How about non-leaf Icon?
    Where can find it, the non-leaf icon (folder -- look)
    to be used for some other place?

    Your welcome for the help you got when you posted your original question:
    http://forum.java.sun.com/thread.jspa?threadID=5204746
    Since you didn't appreciate the help, I won't botheri replying to this question.
    Besides this question is asked all the time in the forum, so if you do some searching you can find the answer.

  • The 'Update Metadata' icon displays even after saving metadata

    After upgrading from v3 to v4.3, I opened my catalog (Lightroom made a copy of the file and converted it for v4.3). I didn't do anything to the images, but noticed several displayed the 'Update Metadata' icon. (I should note the 'update metadata automatically' option in the preferences is turned off to save ROM.)
    Since I update the metadata manually, it's possible I forgot to save these several files — but when I try to save them, the icon persistently returns within seconds, or when I scroll away and come back.
    I'm running an iMac with OS X 10.6.8 and 165 GB of disc space. The Lightroom files are on an external drive, and the images are DNGs.

    rjmooreii wrote:
    The Lightroom files are on an external drive, and the images are DNGs.
    For DNG the best solution is to run the 'Update DNG Preview and Metadata' command, which can be found under the Metadata menu. This method builds a completely new DNG file before removing the old file.
    As to the cause - two known at present:
    1. Auto Exposure or Lens corrections, and
    2. Applying Spot Heal corrections with opacity less than 100%
    The first is complicated by the fact that it's also associated with updating of the thumbnail previews (basically a timing issue) and has been around for a long time, although not everyone sees it. The second is more recent and much easier to reproduce.
    Adobe engineering are aware of these bugs, but I supect that the fix is still some way off. The user level fix for both is as mentioned above, but further develop adjustments can result in it returning.

  • Display issue - horizontal white lines and vertical multicoloured lines.... UNRELATED: constant "update available" icon?

    Hi, my Curve 9300 on the OS 6.0 system has vertical and horizontal lines accross the display, with more appearing every day...   started and the top and left areas of the screen and seem to be slowly migrating & multiplying.
    I tried first turning the phone off and back on again.  Then the battery pull reset.  Now I've tried downloading the OS update direct from the blackberry site and reloading it....   all to no avail.
    Everything is functional, but lines accross the screen are constant.  Since my phone is past warranty anyway, I would like to open it and check the screen connection, but I do not have a torx driver that small to fit the little screw in the back....  Is there anything else I can try, or an easy enough way to remove that screw without having to buy a stupid screwdriver that I will likely never use again...?
    One other thing I've been meaning to find out about...   Despite attempting to update multiple times through the Blackberry Desktop Software, and even now after downloading the update direct from the Blackberry site, my phone continues to display the "update available" icon (with the star in a red circle on a BB outline), and indicates an update required for BB OS 6, yet the desktop software says "no updates available" and I couldn't find anything more recent on the Blackberry site unless there is a way to put OS 7 on the older blackberries.  Why might this be happening and have I missed something?
    Thank you!

    In terms of heat I'm not sure.
    It isn't only one spot that you can push to get it to come back. I have to manipulate the screen carefully in a number of different combinations. Also if the screen brightness is down the and screen fully open with an external monitor on the screen can sometimes clear up even after 4 hours plus of use. If I then move the screen up it will take a few minutes to go bad again. Even if the brightness is left down.
    I actually have a spare screen from an old 400mhz model which is identical brand. Its just not in as good condition and has to bright spots in the corners and one dull area middle bottom. Its just not in as good nic as the current one when its working. Is there a way to 'tighten' the LCD in case its a pressure problem or is still a heat issue?
    Many Thanks, Tre.

  • How to update site icons in the bookmarks without going to every site. This option is available in Maxthon

    when I install fresh and sync my new firefox, I have 100's of bookmarks in categories. I would like to see an option to update site icons where firefox goes and get the icons for all my bookmarks.
    This option is available in Maxthon
    Right now I have to visit every site to have the icon show up.
    maybe there is an addon

    hello daronwade, in order to automatically add the favicons to your synced bookmarks you can try to use the following extension: https://addons.mozilla.org/firefox/addon/faviconreloader/
    after installing the addon you have to initiate the scan for favicons once: press the alt-key to show the menu bar, go to the bookmarks and select the option to reload the favicons.

  • I can't find my "Update IPod" icon

    I can't find my "Update IPod" icon on my ITunes. In place of it there is myname"MP3 Rocket" icon. Where did it go? How do I get it back?
        It's an Ipod nano.

    Did you name your iPOd MP3 rocket when you set it up?

Maybe you are looking for

  • Follow up IE msstree's question

    Thanks to all for your pass help! This is great, I have found most of my questions answered from pass discussions. Don, I have read of your fondless for OS9 and I agree. I have experienced several problem with IE and looking for a new browser I am fi

  • BPC Mass User Management Tool in BPC 10.0 NW-Version Component Error

    Hi, We have a problem when importing request K900024.RBP and R900024.RBP. We changed the UJ_STRING in "DATA: lv_value TYPE uj_value" in the source code as recommended at BPC Mass User Management Tool in BPC 10.0 NW Unfortunately, when we try to impor

  • New ipod touch requires 10.5 can i upgrade from 10.3 to 10.5?

    Hi there, like many other mac users I am now in the position of owning the latest ipod but run an OS that is no longer supported namely OS X 10.3. I have always owned my software and have never infringed any copyright agreements, thus in order to use

  • I own a Macbook Pro 2008 and Airdrop doesn't work? Final Cut Pro X Flop!

    Aidrop: Why does Apple offer such features and then they don't work? Apple is on a mad way i think? Final Cut Pro X: ...also with Final cut Pro!!!! support please! Apple stands for a minority of creative People. There Machines stands for creativity a

  • Problem in 11g tp3 lov

    Hi All, I have a create page with a lov (af:inputListOfValues )field country. But if I run the page, page is coming properly but on clicking of lov I am not getting the lov popup. below is code for your inspection <af:inputText value="#{bindings.ManI