I presume you are populating the JTree with File objects. If not, you need to do this first.

Use a custom renderer that sets the icon. You can use either
FileSystemView fileSystemView =...