Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在mac上获取应用程序的图标?JAVA_Java_Macos - Fatal编程技术网

如何在mac上获取应用程序的图标?JAVA

如何在mac上获取应用程序的图标?JAVA,java,macos,Java,Macos,我试图在mac上获取一个文件的图像,但我找不到任何答案 有一些代码可以在windows上运行 String s = "c:/windows/regedit.exe"; File file = new File(s); sun.awt.shell.ShellFolder sf = sun.awt.shell.ShellFolder.getShellFolder(file); Icon icon = new ImageIcon(sf.getIcon(true)); 对此没有明确的

我试图在mac上获取一个文件的图像,但我找不到任何答案 有一些代码可以在windows上运行

String s = "c:/windows/regedit.exe";
File file = new File(s);

sun.awt.shell.ShellFolder sf =
        sun.awt.shell.ShellFolder.getShellFolder(file);
Icon icon = new ImageIcon(sf.getIcon(true));

对此没有明确的答案。你得自己做些调查。如果Finder中有应用程序,请右键单击并选择“显示软件包内容”。在目录文件夹中,搜索Info.plist文件。您会发现一个条目包含如下内容(我以TextEdit为例):

cfbundleconfile
编辑.icns

进入Resources文件夹,您将在那里找到.icns文件。你可以在中找到如何做到这一点的信息。

对此没有明确的答案。你得自己做些调查。如果Finder中有应用程序,请右键单击并选择“显示软件包内容”。在目录文件夹中,搜索Info.plist文件。您会发现一个条目包含如下内容(我以TextEdit为例):

cfbundleconfile
编辑.icns
进入Resources文件夹,您将在那里找到.icns文件。您可以在中找到有关如何执行此操作的信息

<key>CFBundleIconFile</key>
<string>Edit.icns</string>