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
object from the local file system:
javax.swing.filechooser.FileSystemView.getFileSystemView().getSystemIcon( file )
for a 16x16 icon or for a bigger one:
sun.awt.shell.ShellFolder.getShellFolder( file ).getIcon( true ) )
Since my files are stored in a database, I don't have the File
object. My workaround is to create a temp file with the specific filename extension, use one of the two methods above and cache the icon to display it in a CellRenderer.
I searched for a solution without temporary files and found two I don't like either:
org.eclipse.swt.program.Program.findProgram(String extension).getImageData()
, but I don't want to use SWT
org.jdesktop.jdic.icons.IconService
from the Incubator of the JDIC project. The last changes on the IconService
are 6 years ago, on JDIC 2 years ago and I can't find a downloadable jar.
Is there another solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…