import java.io.*;
import javax.swing.*;
import javax.imageio.*;
public class IconExtract {
public static void main(String[] args) throws Exception {
File file = new File("C:/windows/regedit.exe");
//Obtener metadata y crear un icono
sun.awt.shell.ShellFolder sf = sun.awt.shell.ShellFolder.getShellFolder(file);
Icon icon = new ImageIcon(sf.getIcon(true));
System.out.println("type = " + sf.getFolderType());
//mostrar el icono
JLabel ficon = new JLabel(s, icon, SwingConstants.LEFT);
/*Modo 2 (miniatura)
//Obtener metadata y crear un icono
Icon icon = javax.swing.filechooser.FileSystemView.getFileSystemView().getSystemIcon(file);
//mostrar el icono
JLabel ficon = new JLabel(s, icon, SwingConstants.LEFT);
*/
JFrame frame = new JFrame();
frame.getContentPane().add(ficon);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
jueves, 23 de abril de 2009
Suscribirse a:
Enviar comentarios (Atom)



No hay comentarios:
Publicar un comentario