The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing.filechooser  [19 examples] > Icons  [2 examples]

e902. Getting the Large File-Type Icon of a File

This example uses an unsupported class - - sun.awt.shell.ShellFolder - - and therefore will not work in all virtual machines.
    // Create a File instance of the file
    File file = new File("filename.txt");
    
    try {
        sun.awt.shell.ShellFolder sf = sun.awt.shell.ShellFolder.getShellFolder(file);
    
        // Get large icon
        Icon icon = new ImageIcon(sf.getIcon(true), sf.getFolderType());
    } catch (FileNotFoundException e) {
    }

 Related Examples
e901. Getting the File-Type Icon of a File

See also: Events    Hidden Files    Layout    Selections   


© 2002 Addison-Wesley.