Swing/SystemIcon のバックアップの現在との差分(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/SystemIcon へ行く。
- 1 (2008-06-30 (月) 17:25:49)
- 2 (2012-05-10 (木) 11:20:12)
- 3 (2013-01-20 (日) 23:40:34)
- 4 (2015-07-15 (水) 19:07:46)
- 5 (2017-04-02 (日) 03:08:34)
- 6 (2018-03-18 (日) 10:05:42)
- 7 (2018-10-12 (金) 17:41:27)
- 8 (2020-10-08 (木) 15:39:47)
- 9 (2021-03-15 (月) 12:03:54)
- 10 (2021-03-15 (月) 14:13:11)
- 11 (2022-08-20 (土) 22:15:25)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:SystemIconを取得する #navi(../) *SystemIconを取得する [#k9549786] Posted by [[terai]] at 2008-06-30 --- 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 --- * 概要 [#summary] ファイル、ディレクトリなどの`SystemIcon`を取得します。 #contents #download(https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTUG6tI4SI/AAAAAAAAAlg/bci1geT80EM/s800/SystemIcon.png) **概要 [#lf88610d] ファイル、ディレクトリなどのSystemIconを取得します。 //-&jnlp; -&jar; -&zip; #screenshot **サンプルコード [#b874c8ce] #code{{ * サンプルコード [#sourcecode] #code(link){{ // 16x16 smallLabel.setIcon(FileSystemView.getFileSystemView().getSystemIcon(file)); }} #code{{ // 32x32 largeLabel.setIcon(new ImageIcon(ShellFolder.getShellFolder(file).getIcon(true))); }} **解説 [#g2997187] 上記のサンプルでは、Windows環境でファイルをドロップするとそのファイルのSystemIconを表示することが出来ます。 * 解説 [#explanation] 上記のサンプルでは、`Windows`環境などからファイルをパネルにドロップするとそのファイルの`SystemIcon`を表示できます。 - 16x16 -- FileSystemView#getSystemIcon(File f) で小さいアイコンを取得 - `16x16` -- `FileSystemView#getSystemIcon(File)`メソッドで小さいアイコンを取得可能 - `32x32` -- `ShellFolder.getShellFolder(file).getIcon(true)`で大きいアイコンを取得可能 -- コンパイル時に「`ShellFolder`は内部所有の`API`であり、今後のリリースで削除される可能性があります」と警告される -- `Java 9`では`sun`パッケージの内部所有クラスは非公開になって使用できない -- `Java 17`で復活しそう? --- [https://bugs.openjdk.org/browse/JDK-8182043 [JDK-8182043] Access to Windows Large Icons - Java Bug System] --- [https://github.com/openjdk/jdk/pull/2875 8182043: Access to Windows Large Icons by azuev-java · Pull Request #2875 · openjdk/jdk · GitHub] - 32x32 -- ShellFolder.getShellFolder(file).getIcon(true) で大きいアイコンを取得 -- 「sun.awt.shell.ShellFolder は Sun が所有する API であり、今後のリリースで削除される可能性があります。」と警告される * 参考リンク [#reference] - [https://docs.oracle.com/javase/jp/8/docs/api/javax/swing/filechooser/FileSystemView.html#getSystemIcon-java.io.File- FileSystemView#getSystemIcon(File) (Java Platform SE 8)] - [http://blog.codebeach.com/2008/02/get-file-type-icon-with-java.html Code Beach: Get the File Type Icon with Java] - [https://github.com/openjdk/jdk/pull/2875 8182043: Access to Windows Large Icons by azuev-java · Pull Request #2875 · openjdk/jdk · GitHub] **参考リンク [#k6280a75] -[[Code Beach: Get the File Type Icon with Java>http://blog.codebeach.com/2008/02/get-file-type-icon-with-java.html]] **コメント [#w80dd0d3] * コメント [#comment] #comment #comment