jEdit Community - Resources for users of the jEdit Text Editor
Usage of GUIUtilities.loadIcon
Submitted by Hamza on Saturday, 17 May, 2008 - 14:13
Hi folks,

I am trying to modify the QuickNotepad sources to add an extra button to the tool panel (QuickNotepadToolPanel.java) but whatever I do I can't seem to load a PNG file as the button icon.

I've added the following bit to QuickNotepadToolPanel.java to add the actual button:

add(makeCustomButton("msp430.foo", new ActionListener() {
public void actionPerformed(ActionEvent evt) {
QuickNotepadToolPanel.this.pad.foo();
}
}));

..and I have specified the icon files in the props file as:

QuickNotepad.foo.icon=foo.png
QuickNotepad.foo.label=Foo

the icon foo.png resides in the same folder as the java sources and the code compiles just fine but the icon is not loaded when I load the plugin and the button is just the size of a tiny dot.

If I specify an absolute path the code compiles but jEdit chokes on startup and I have to kill it.

Do I need to somehow specify the icon location in the build.xml file? Can I manually add the files to the jar itself?


Quite an easy question I guess but it has been driving me crazy so any comments/help much appreciated.


Cheers,
Hamza.
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Correction: add(makeCustom
by Hamza on Sat, 17/05/2008 - 14:17
Correction:

add(makeCustomButton("QuickNotepad.foo", new ActionListener() {
public void actionPerformed(ActionEvent evt) {
QuickNotepadToolPanel.this.pad.foo();
}
}));
 
prefix file:
by Robert Schwenn on Tue, 20/05/2008 - 20:25
I only know how to customize icons via properties files. But I guess it's the same when coding a plugin:

1. When using a relative path (or a name without a path) the icon has to be found in jedit.jar where all the other standard icons are stored.

2. When using an external icon, it has to be specified by full path preceding "file:", i.e. "file:G:\\tools\\jedit\\icons\\test.png"

Robert
 
This is an old comment, but f
by Robotron2084 on Sun, 22/11/2009 - 21:59
This is an old comment, but figured I'd reply to give some novice plugin developers like myself some advice.

It looks as though there is a mapping from 'old' ways of loading icons to the new way. The QuickNotepadPlugin uses the old way. The mappings in the GUIUtilities.java source looks like this:

deprecatedIcons.put("Open.png", "22x22/actions/document-open.png");

So if you want to use an icon that isn't in the deprecatedIcons file but is within jEdit you need to specify a path that is relative to the icons/themes/$THEME/ folder.

Example:

quicknotepad.choose-file.icon=22x22/actions/document-print.png
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300