import java.io.File;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import sun.awt.shell.ShellFolder;
public class ShellFolderIcon {
public static void main(final String[] args) throws FileNotFoundException {
final File file = new File("C:\\Windows\\regedit.exe");
final ShellFolder folder = ShellFolder.getShellFolder(file);
final Icon icon = new ImageIcon(folder.getIcon(true));
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final JLabel label = new JLabel(file.toString(), icon, SwingConstants.CENTER);
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(label);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
}