I'm making a basic file browser and wish to display the icon of each file. Is there any way to get this?
            Asked
            
        
        
            Active
            
        
            Viewed 7,273 times
        
    11
            
            
        - 
                    is this for all operating systems or just windows? – pstanton Dec 06 '10 at 04:39
- 
                    @pstanton All operating systems. [I know this is late, but I wanted it here in case someone else came by and had the same question] – Ky - Oct 01 '16 at 06:43
1 Answers
13
            Icon icon = FileSystemView.getFileSystemView().getSystemIcon( File );
 
    
    
        camickr
        
- 321,443
- 19
- 166
- 288
- 
                    2This doesn't work well on OS X, it only returns a folder for directories or a generic file icon for any non-directories. – Sam Barnum Dec 15 '12 at 04:16
- 
                    
- 
                    2Workaround for os x: `final javax.swing.JFileChooser fc = new javax.swing.JFileChooser(); Icon icon = fc.getUI().getFileView(fc).getIcon(file);` – zella Oct 21 '15 at 07:43
