I want to change different icon for different leaf node

Hi,
i am reading file system(win 2000)and showing in a tree.i want to
show different icon for different file extension.
Pl suggest me with sample code,how should i do?
Thanx

Hi...
To do this, u need to write ur own TreeCellRenderer.
ex :
class FileSystemTreeCellRenderer extends JLabel implements TreeCellRenderer
     File file= null;
     public FileSystemTreeCellRenderer(File f)
          this.file = f;
     public Component getTreeCellRendererComponent
               JTree tree,
               Object value,
               boolean selected,
               boolean expanded,
               boolean leaf,
               int row,
               boolean hasFocus
          if(file.isDirectory())
               setIcon("your image");
               setText("file/dir name");
          else
               setIcon("your other image");
               setText("file/dir name");
     return this;
Hope it suits ur need .. (also, using the file extensions, u can set different icons following the above strategy...)
Regards,
Ramanujam

Similar Messages

  • How I change the icon for iTunes songs?

    When I drag iTunes songs onto my desktop the icon is white with a gray iTunes icon. How can change this icon for all of my iTunes songs?

    Thanks Patrick. I used Control-Click on the actual audio file on my desktop opened the Show View Options menu and turned off the icon preview option. That changed my icons from gray with a white background to red with a white background which is exactly what I wanted.  You pointed me in the right direction. Appreciate it.

  • How to change the icon for print dialog?

    Hello,
    I have a JTable, and with the print() method, I'm able to bring up the Print dialog and successfully print the contents of the table. Example:
    myTable.print( JTable.PrintMode.FIT_WIDTH, myHeaderFormat, myFooterFormat );This works great, but one small detail I'd like to change is the icon in the top-left corner of the dialog. The icon is currently the default Java coffee cup icon, while the rest of my application uses my custom icon. I couldn't find any documentation in the API or tutorials that Java has listed which shows how to change the icon, so I'm not even sure if it's possible (but why shouldn't it be?).
    My question is this: Is it possible to change the default icon in the print dialog? Or do I have to either make my own print dialog somehow, or use a third-party print dialog?
    Thanks

    tjacobs01: Appreciate the assistance (despite your sass). I've already searched the API, tutorials, and this forum. I'm already well aware of the setIconImage() method for JFrame -- after all, that's how I set the icon for my other frames as I previously mentioned. However, I want to set the icon for the print dialog called from the print() method of JTable.
    How would I use setIconImage() for the print() method of JTable? The print() method returns a boolean value, not a JFrame, so I'm just not sure how to implement what you're saying.
    Thanks

  • How to change the Icon for a JFileChooser ?

    Has anyone figured out how to change the icon for an instance of JFileChooser from the coffee cup to something else?
    I'm on 1.4
    Thanks,
    Ken

    Never mind. I figured it out.
    You have to use an instance of JFrame in the call to showXxxxDialog(Component c). Set the icon of the JFrame to what you want the JFileChooser's icon to be.

  • HT4059 I downloaded iBooks Author in Italy so the interface is in Italian.  I want to change to English for the entire interface?

    I downloaded iBooks Author in Italy so the interface is in Italian.  I want to change to English for the entire interface?

    You would have to re download iBooks Author from the U.S. App Store. Launch the App Store then click the round flag icon bottom right side of the window. Select United States
    The issue with this is that your billing credentials (regardless of whether or not it's a free or paid app) must be associated with the same country where you reside. So you may not be able to re download iBooks Author in English.
    Post your topic in the iBooks Author community here.
    More iBooks Author users can offer feedback that way and may know of a work around.
    This is the, "iTunes Store" community for help with iOS devices.

  • My MacBook Pro keeps making copies of a document that I am trying to save. I don't want to duplicate the file. I only want to save it on both my hard drive and my external hard drive. I do not want to change its name for every save, which the computer see

    My MacBook Pro keeps making copies of a document that I am trying to save. I don't want to duplicate the file. I only want to save it on both my hard drive and my external hard drive. I do not want to change its name for every save, which the computer seems insistent on doing. Help!!

    11lizzyp wrote:
    can't be saved because the file is read-only.
    I did not create the file to be read-only. I created to be able to continue to add to it as I work on it.
    More on versions here:
    http://support.apple.com/kb/ht4753
    local snapshots:
    http://support.apple.com/kb/HT4878
    Sounds like a permissions problem ie read only.
    If running repair permissions from your DiskUtility.app does not sort it,
    Someone should jump in here with erudite and concise fix.

  • How to change the icon for 'windows group' in Java 1.6 [Windows XP] ?

    Hello,
    I was wondering if there is a possibility to change the icon for 'windows group' in Java 1.6...
    I'm using Windows XP SP2. Now the windows from my Java 1.6 application are grouped with the standard Sun icon [screen below] on the group.
    http://img382.imageshack.us/img382/8995/iconbl1.png
    I would like to change the icon for my own. Is there a way to do that ?
    Please help.

    Whichever icon I use for the main frame (I tried few), after grouping the main frame and other sub-frames the icon is changed to standard 'Java Sun' icon as you can see in the screenshot from my first post. The problem occurs only when frames are grouped, when the are separated in the task bar their titles and icons are ok...
    So how can I change the icon/title for the group only (for Java 1.6 in Windows XP) ?

  • How do i change an icon for a device?

    How do I change an icon for a device?

    If it's a desktop icon, then CMD+I, select the icon, and paste in the substitute. This is what my boot volume looks like.

  • After 2 years want to change depreciation key for a asset

    Hi,
    For a particular asset we want to change depreciation key for this asset already we have posted depreciation for 2 years. After 2 years user realizes they are using wrong depreciation key now they want to change depreciation key for a particular asset.  In new financial year till now they have not posted depreciation .I just want to now what is the impact of this changes how we will adjust the value in future because previously they are calculating depreciation  1.63% now they want to calculate depreciation 3.33 % can any one tell me about the future impact of asset.
    How we will adjust the value?
    Thanks and Regards,
    Neha

    Hi,
    Does your user wants to post the depreciation for closed Fiscal years?
    If yes First calculate unplanned depreciation for the difference up to the last closed fiscal year and post in the current year.
    Now after posting this then change the depreciation key in the asset master and in the next run the system identifies the difference between posted value with the old Key and teh correct key and adjusts the difference in the current period depreciation run.
    If the user don't want to post the values of the previous years, change the key in asset master so that the difference in the depreciation from the start of the fiscal year is adjusted in the current period.
    Future impact if the option is second the asset life will be more when compared to the actual life. In first case there is no effect.
    Provide Business with these two solutions and they have to choose between the options.
    Reward points if useful.
    Sarma

  • How can I change the icon for incoming messages on iChat?

    I already changed the icon for the ichat app, but whenever i get a new message it reverts back to the original icon with a number on the corner. I have an icon for the alternating messages i just don't know how to change it. HELP?!

    Hi,
    It's a long time since I changed an Icon on anything on my computer.
    The icon for the App is stored in the App and there are two ways to change  it.
    You can do a  Get Info (CMD and i Keys together) on the app itself and then Paste a new icon to the top field.
    The other way is to edit/change the icns file in the App itself.
    Right/Control Click the app and choose Show Package Contents.
    Open the Contents folder then Resources and the iChat.icns file is in there
    I am presuming that if you use the first method - the bit that puts the Red area with the number in it uses something else (possibly the icns file)
    I cannot find any "supply" of the red numbers.  In fact I use Chax (An iChat Add-On) that changes this  to the first part of the first IM that is not read - which suggests the red area is the important bit.
    If you do try to edit the .icns file I would save the Original first.
    8:10 PM      Monday; April 18, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
    Message was edited by: Ralph Johns (UK)

  • How can I change the icon for the bookmarks menu button

    Using linux, the default icon for the bookmarks menu button is quite ugly. Is there a way to change the icon for the button with some code in userChrome.css ?

    After several intents, I found a solution.
    This is my userChrome.css file:
    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
    toolbarbutton[class="toolbarbutton-1"]#bookmarks-menu-button image[class="toolbarbutton-icon"] {
    list-style-image: url("bookmark_gray.png") !important;
    -moz-image-region: rect(0px, 0px, 0px, 24px) !important;}
    Probably it's messy but works.

  • I want to change my email for creative cloud, and have uninstalled and reinstalled cc, but it hasn't changed yet! How can i change my email??

    I want to change my email for creative cloud, and have uninstalled and reinstalled cc, but it hasn't changed yet! How can i change my email??

    Change Account https://forums.adobe.com/thread/1465499 may help
    or
    Adobe contact information - http://helpx.adobe.com/contact.html

  • I want to change my email for my Apple ID if I change I will lose the credits that I have in the account?

    I want to change my email for my Apple ID if I change I will lose the credits that I have in the account?

    See Kappy's previous write-up.
    Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities

  • I want to change Material Type for mass upload.(MMAM)

    hi all,
    I want to change Material Type for mass upload.(MMAM)
    Suggestion pls? or Any BAPI is availablre?
    Edited by: abap_friends on Jan 6, 2011 7:12 AM
    Moderator message: please do your own research before asking.
    Edited by: Thomas Zloch on Jan 6, 2011 11:27 AM

    This may be little tough for 10000 sales orders.
    1. You have to remove the output record for the irrelevant output record using tcode VV12 for the relevant document type. So now for the document type, the old output wont be triggered.
    2. Now, create output records for hte correct output type in VV11 tcode(for the output type BA03) for the document type. Now this output will be triggered for all the document types you are creating from now onwards.
    3. To trigger the output type BA03, in all the old orders, you just have to open these sales orders in change mode (VA02), and just save it. When u open it the output type BA03 will be automatically triggered as the master data is maintained in VV11. But because just opening all the 10000 sales orders in VA02 one by one be a mechanical task, you have to think of some tool for this.
    May be a CATT procedure can do the trick. Else, you can just create a small program, where you can upload these sales orders and the program will just open these orders in change mode and just saves it (without making any changes). Then the output will be retriggered.
    Here again, if you are printing the output directly, it is advisable to trigger the output in batch mode(Date/Time field is 1 in VV11), and then you can again trigger the printing again using the program RSNAST00 after office hours for these 10k orders.
    I hope I answered ur query.
    Pls lemme know if you need some more info. (You can reward me too...)

  • I want to change my password for apple id but i forgot my secrect question as well as the email add that apple sends the reset link to. How can it be resolved ?

    I want to change my password for apple id but i forgot my secrect question as well as the email add that apple sends the reset link to. How can it be resolved ?

    See Kappy's previous write-up.
    Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities

Maybe you are looking for

  • Error creating instance of class from same package

    When I try to create an instance of a class that is in the same package, my IDE indicates that the constructor can not be found. Can anyone tell me what is wrong? Thanks. Below are the codes for both classes: package com.practice; import java.applet.

  • [JS] (CS3) eventListener & doScript

    Hello everyone, Is it possible to create an eventListener, like "afterOpen" that would trigger a script file? In CS2, I wrote a few scripts that were managed by inEventScript Plug-in. We are upgrading to CS3 and this plug-in was not transported to CS

  • "song could not be used because original file could not be found..."

    My entire music library files cannot be found. When I click on a song I get a popup that says "song could not be used because the original file could not be found. Would you like to locate it?" I can't find the files anywhere, can't open any from my

  • Why does an error message come up when I try to download an app

    I have about 10 apps I am trying to update but everytime I click the app to get it to start loading a message comes up saying that the app could not be downloaded at this time. I don't know what to do because I can't use the 10 apps until I can get t

  • My iphone4's one speaker is only working

    my iphone4's one speaker is only working. send me some suggestions ...wat to do for it ...