【发布时间】:2017-01-06 10:16:31
【问题描述】:
我制作了一个自定义 Eclipse 插件,它使用并显示多个对话框,我想知道是否可以将左上角的图标图像设置为我在插件的 icons 文件夹中使用的那个。我想获取该图标并设置它,而不是 Eclipse 使用的默认图标。
我正在重写configureShell() 方法来更改对话框标题,我还想更改图标。
@Override
protected void configureShell(Shell parent){
super.configureShell(parent);
parent.setText("Choose variant...");
Image icon = new Image(parent.getDisplay(), "icons/best.gif"); - this method does not work as it cannot find the file
parent.setImage(icon);
}
我也尝试使用getClass().getResource("best.gif") 并将图像放在同一个包中,但仍然找不到我提供的位置(FileNotFoundException),而且Image 构造函数不接受 URL 对象。
@Override
protected void configureShell(Shell parent){
super.configureShell(parent);
parent.setText("Choose variant...");
Image icon = new Image(parent.getDisplay(), getClass().getResource("icons/best.gif"));
parent.setImage(icon);
}
有没有办法使用我的 Eclipse 插件中已有的图标?
主要问题是从插件的icons 文件夹中获取图标并将其设为Image 对象。
谢谢。
【问题讨论】: