How to create control with custom palette icon?

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

How to create control with custom palette icon?

Postby lenik » Mon Sep 21, 2009 8:19 pm

I've created a custom SWT control MyControl, and added to SWT Designer's palette.
It works.
And then I create a bean info class MyControlBeanInfo, which exports getIcon(kind).
When add class MyControl to palette, I can see the icon image in the Create Entry dialog, but after added, the icon turned back to the default icon in the palette.

If I implement BeanInfo on MyControl, rather than create a separate class MyControlBeanInfo, I can always see the icon image.
But according to java beans spec, I don't have to implement BeanInfo on MyControl, and the two classes should be separated.
lenik
 
Posts: 2
Joined: Mon Sep 21, 2009 8:13 pm

Re: How to create control with custom palette icon?

Postby Eric Clayberg » Wed Sep 23, 2009 12:08 pm

The easiest way to associate an icon with a control is to just place a PNG or GIF image with same name as the component into the same package or into a sub-folder of /wbp-meta that matches the folder structure containing the actual component. For example, if you have a widget names com.foo.MyWidget, then add a image file named /com/foo/MyWidget.png or /wbp-meta/com/foo/MyWidget.png.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: Google [Bot] and 2 guests