• category: swing folder: SystemIcon title: FileのSystemIconを取得する tags: [SystemIcon, FileSystemView, ShellFolder] author: aterai pubdate: 2008-06-30T17:25:49+09:00 description: ファイル、ディレクトリなどのSystemIconを取得します。 image: https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTUG6tI4SI/AAAAAAAAAlg/bci1geT80EM/s800/SystemIcon.png

概要

ファイル、ディレクトリなどのSystemIconを取得します。

サンプルコード

#spandel
//16x16
#spanend
#spanadd
// 16x16
#spanend
smallLabel.setIcon(FileSystemView.getFileSystemView().getSystemIcon(file));
#spandel
//32x32
#spanend
#spanadd
// 32x32
#spanend
largeLabel.setIcon(new ImageIcon(ShellFolder.getShellFolder(file).getIcon(true)));
View in GitHub: Java, Kotlin

解説

上記のサンプルでは、Windows環境でファイルをドロップするとそのファイルのSystemIconを表示することが出来ます。 上記のサンプルでは、Windows環境などからファイルをパネルにドロップするとそのファイルのSystemIconを表示できます。
  • 16x16
    • FileSystemView#getSystemIcon(File f)で小さいアイコンを取得
    • FileSystemView#getSystemIcon(File)メソッドで小さいアイコンを取得可能
  • 32x32

参考リンク

コメント