|
Re: Simple question: image on button gives red square [message #460469 is a reply to message #460465] |
Mon, 29 August 2005 15:37 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
It means it can't find the image on disk. The red square is the "missing
image" image that is returned when it can't find the image.
In your example below:
- First I make the assumption that DialogCellEditor() is your
celleditor, and for this example let's call it: com.mine.DialogCellEditor.
- So for this example to work, the images directory must be in your
classpath and it must be under the com/mine directory. That is because
the createFromFile(class, path) uses class.getResourceAsStream(path) to
find the image. Since you had no leading '/' on the path, it will
automatically take the package name of the class (i.e. "com.mine") and
change the '.' to '/' and prefix that to the path. So in your case it
will look in the classpath for "/com/mine/images/dots_button.gif"
Koen van Dijken wrote:
> I have a Button on which I try to put an image
>
> static {
> ImageRegistry reg = JFaceResources.getImageRegistry();
> reg.put(CELL_EDITOR_IMG_DOTS_BUTTON, ImageDescriptor.createFromFile(
> DialogCellEditor.class,
> "images/dots_button.gif"));//$NON-NLS-1$
> }
>
>
> and later when the Button is created:
>
> Button button = new Button(parent, SWT.DOWN);
> button.setImage(JFaceResources.getImageRegistry().get(
> CELL_EDITOR_IMG_DOTS_BUTTON));
>
> I get a small red square on the button instead of the image. The image is
> loaded succesfully in the ImageRegistry. The button is large enough to
> accomodate the image.
>
> What am I doing wrong?
>
> Koen
>
>
>
--
Thanks,
Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.03439 seconds