SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.
Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg
by deffer » Tue Mar 09, 2010 8:11 am
Hi all, I am developing an eclipse plugin application. In the icons folder there are some images to be displayed by the application. I have made sure that the icons folder is included in the bin.includes section of the build.properties file, but the application tries to show the images they are not found. I am using SWTResourceManager.getImage("icons/Selection.bmp") but a red square appears in the application instead of the actual image. I have unsuccessfully tried all variants of the image path ("/icons/Selection.bmp" - "Selection.bmp"). Where should the icons folder be placed in order for them to be read by the SWTResourceManager?
Thanks in advance
-
deffer
-
- Posts: 3
- Joined: Tue Mar 09, 2010 8:00 am
by Konstantin.Scheglov » Wed Mar 10, 2010 4:26 am
I'm not sure about structure of your project.
In case of simple SWT application you can put images into classpath, use "Classpath resource" in image selection dialog.
- Code: Select all
{
Button button = new Button(m_shell, SWT.NONE);
button.setImage(SWTResourceManager.getImage(Application_1.class, "/test/icons/folder_package.gif"));
button.setText("New Button");
}
- Attachments
-
- Project structure
- Screenshot - 10.03.2010 , 15_24_48.png (8.67 KiB) Viewed 294 times
-
Konstantin.Scheglov
- Moderator
-
- Posts: 186
- Joined: Tue Oct 18, 2005 8:11 pm
- Location: Russian Federation, Lipetsk
-
by deffer » Wed Mar 10, 2010 6:24 am
Image is the classpath, it is in the icon folder of the src/main/resources folder which is in the classpath. I use SWTResourceManager.getImage("/incon/Selection.bmp"); but instead a red square keeps showing up
- Attachments
-
- forum.JPG (29.31 KiB) Viewed 293 times
-
deffer
-
- Posts: 3
- Joined: Tue Mar 09, 2010 8:00 am
by Eric Clayberg » Wed Mar 10, 2010 6:43 am
Are your icons being packaged as part of your plugin?
Feel free to send us a complete test case that illustrates the problem.
-
Eric Clayberg
- Moderator
-
- Posts: 4503
- Joined: Tue Sep 30, 2003 6:39 am
- Location: Boston, MA USA
-
by deffer » Wed Mar 10, 2010 7:13 am
I am sure that images are packed with the rest of the application. I have found a workaround, I had to add a dummy class (DummyClass) to the icon folder and call the SWTResourceManager.getImage(DummyClass.class,"/icon/Selection.bmp") method and it works, if you are aware of any other solution please let me know.
Thanks
-
deffer
-
- Posts: 3
- Joined: Tue Mar 09, 2010 8:00 am
by Konstantin.Scheglov » Thu Mar 11, 2010 12:36 am
Works for me with attached project.
- Code: Select all
{
Button button = new Button(m_shell, SWT.NONE);
button.setImage(SWTResourceManager.getImage(Application_1.class, "/icons/preference_transfer.png"));
button.setText("New Button");
}
- Attachments
-
- Project structure
- Screenshot - 11.03.2010 , 11_36_57.png (9.44 KiB) Viewed 289 times
-
- swt_testMaven.zip
- Sample project
- (21.06 KiB) Downloaded 25 times
-
Konstantin.Scheglov
- Moderator
-
- Posts: 186
- Joined: Tue Oct 18, 2005 8:11 pm
- Location: Russian Federation, Lipetsk
-
Return to SWT Designer
Who is online
Users browsing this forum: Google [Bot] and 2 guests