Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all different sizes of system icon of a file

Tags:

java

icons

swing

I'm doing a piece of code in java and I need to get different sizes of system icons of files. I know that for getting file system icons, i should use this:

File file = new File("Whatever.txt");
FileSystemView view = FileSystemView.getFileSystemView();
Icon icon = view.getSystemIcon(file);

but this code returns the smallest size of icon. What sholud I do for getting other sizes?

like image 883
mehrmoudi Avatar asked Feb 06 '12 18:02

mehrmoudi


1 Answers

For 32x32 Icon you can use ShellFolder.

sun.awt.shell.ShellFolder.getShellFolder( file ).getIcon( true ) 

Or use a JNI Api . Both "solutions" already discuted here

like image 54
fhofmann Avatar answered Sep 20 '22 15:09

fhofmann