Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Getting the Large File-Type Icon of a File

import java.io.File; import javax.swing.Icon; import javax.swing.ImageIcon; import sun.awt.shell.ShellFolder; public class Main {   public static void main(String[] argv) throws Exception {     File file = new File("filename.txt");     ShellFolder sf = ShellFolder.getShellFolder(file);     Icon icon = new ImageIcon(sf.getIcon(true), sf.getFolderType());   } }