• 追加された行はこの色です。
  • 削除された行はこの色です。
TITLE:FileのSystemIconを取得する
#navi(../)
#tags()
RIGHT:Posted by &author(aterai); at 2008-06-30
*FileのSystemIconを取得する [#k9549786]
ファイル、ディレクトリなどのSystemIconを取得します。
---
title: FileのSystemIconを取得する
tags: [SystemIcon, FileSystemView, ShellFolder]
author: aterai
pubdate: 2008-06-30T17:25:49+09:00
description: ファイル、ディレクトリなどのSystemIconを取得します。
---
* 概要 [#k9549786]
ファイル、ディレクトリなどの`SystemIcon`を取得します。

//-&jnlp;
-&jar;
-&zip;
#download(https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTUG6tI4SI/AAAAAAAAAlg/bci1geT80EM/s800/SystemIcon.png)

//#screenshot
#ref(http://lh4.ggpht.com/_9Z4BYR88imo/TQTUG6tI4SI/AAAAAAAAAlg/bci1geT80EM/s800/SystemIcon.png)

**サンプルコード [#b874c8ce]
* サンプルコード [#b874c8ce]
#code(link){{
//16x16
smallLabel.setIcon(FileSystemView.getFileSystemView().getSystemIcon(file));
}}
#code{{
//32x32
largeLabel.setIcon(new ImageIcon(ShellFolder.getShellFolder(file).getIcon(true)));
}}

**解説 [#g2997187]
上記のサンプルでは、Windows環境でファイルをドロップするとそのファイルのSystemIconを表示することが出来ます。
* 解説 [#g2997187]
上記のサンプルでは、`Windows`環境でファイルをドロップするとそのファイルの`SystemIcon`を表示することが出来ます。

- 16x16
-- FileSystemView#getSystemIcon(File f) で小さいアイコンを取得
- `16x16`
-- `FileSystemView#getSystemIcon(File f)`で小さいアイコンを取得
- `32x32`
-- `ShellFolder.getShellFolder(file).getIcon(true)`で大きいアイコンを取得
-- 「`ShellFolder`は内部所有の`API`であり、今後のリリースで削除される可能性があります」と警告される
//「`sun.awt.shell.ShellFolder` は Sun が所有する `API` であり、今後のリリースで削除される可能性があります。」

- 32x32
-- ShellFolder.getShellFolder(file).getIcon(true) で大きいアイコンを取得
-- %%「sun.awt.shell.ShellFolder は Sun が所有する API であり、今後のリリースで削除される可能性があります。」と警告される%%
-- 「ShellFolderは内部所有のAPIであり、今後のリリースで削除される可能性があります」と警告される
* 参考リンク [#k6280a75]
- [http://blog.codebeach.com/2008/02/get-file-type-icon-with-java.html Code Beach: Get the File Type Icon with Java]

**参考リンク [#k6280a75]
-[http://blog.codebeach.com/2008/02/get-file-type-icon-with-java.html Code Beach: Get the File Type Icon with Java]

**コメント [#w80dd0d3]
* コメント [#w80dd0d3]
#comment
#comment