Intellij插件找不到图标路径

问题描述 投票:0回答:1

我正在尝试为IntelliJ开发的工具窗口插件添加一个图标。我按照here发现的说明进行操作,但IntelliJ报告了以下异常:

ERROR - tellij.openapi.util.IconLoader - Icon cannot be found in 'icons/icon.png', aClass='interface icons.PluginIcons'

我的项目结构是

...
- resources
--- icons
----- icon.png
----- [email protected]
----- icon@2x_dark.png
----- icon_dark.png
- src
--- com
----- micbakos
------ LocationToolWindow.java
--- icons
---- PluginIcons.java
...

PluginIcons界面:

package icons;

import com.intellij.openapi.util.IconLoader;

import javax.swing.*;

public interface PluginIcons {
    Icon EDIT_LOCATION_ICON = IconLoader.getIcon("icons/icon.png");
}

和plugin.xml

<extensions defaultExtensionNs="com.intellij">
    <toolWindow
            id="Location Tool"
            anchor="right"
            factoryClass="com.micbakos.LocationToolWindow"
            icon="PluginIcons.EDIT_LOCATION_ICON"/>
  </extensions>

暗示

编辑器似乎识别出图标并将其显示在代码Icon EDIT_LOCATION_ICON = IconLoader.getIcon("icons/icon.png");的左侧窗格上的行号,并且当我在icon="PluginIcons.EDIT_LOCATION_ICON"上时,plugins.xml PluginIcons.java跳到⌘+click上,所以一切似乎都正确连接。

intellij-idea intellij-plugin
1个回答
0
投票

正如Meo指出要寻找导出的jar,我找了out文件夹。 IntelliJ似乎在PluginIcons.class包中包装了icons

所以我改变了PluginIcons.java的代码看起来像这个Icon EDIT_LOCATION_ICON = IconLoader.getIcon("icon.png");

现在,当我运行代码时出现了插件的图标,但是当我点击"icon.png"时代码跳转不起作用。 _(ツ)_ /¯

© www.soinside.com 2019 - 2024. All rights reserved.