How to get the icon for a file extension or filetype without creating a temp file?

后端 未结 2 1051
耶瑟儿~
耶瑟儿~ 2020-12-24 03:13

I list some filenames with their icons (like the ones in the Windows Explorer) in a JTable. I know the two ways to get the icon if I have a File ob

2条回答
  •  孤独总比滥情好
    2020-12-24 03:52

    Looks like you already discovered the way to do it, unless you want to dive into native libraries etc.

    FileSystemView uses Win32ShellFolder internally so they are basically the same.

    I also dug up the Source for org.eclipse.swt.program.Program and with it org.eclipse.swt.internal.win32.OS. The OS class then uses a native call for the Icon. At this point unless you really really cannot create a Temp File i would not go down that path.

    For JDIC i only found http://kickjava.com/src/org/jdesktop/jdic/tray/internal/impl/WinTrayIconService.java.htm with a little bit of digging(may not be related but does icony things :D). Also calls native.

提交回复
热议问题