Results 1 to 5 of 5
  1. #1
    janice is offline Member
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Default Can not load image in SWT/Eclipse

    I'm writing an Eclipse plugin (following an example I found on the net) and try to load small icons in a table. In my LabelProvider class I have this:

    static {
    String iconPath = "icons/";
    imageRegistry.put(
    CHECKED_IMAGE,
    ImageDescriptor.createFromFile(
    EbbTableViewer.class,
    iconPath + CHECKED_IMAGE + ".gif"));

    ... more the same...

    }

    and here's the method that gets the image:

    private Image getImage(boolean isSelected) {
    String key = isSelected ? CHECKED_IMAGE : UNCHECKED_IMAGE;
    return imageRegistry.get(key);
    }

    But no image is drawn. I got this error:

    Unable to create resource File ImageDescriptor

    Any ideas?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Please post the FULL text of the error message without edits.

  3. #3
    janice is offline Member
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Default

    ok, this is the FULL text:

    The image could not be loaded: FileImageDescriptor(location=class tableviewerexample.TableViewerExample, name=icons/unchecked.gif)
    org.eclipse.jface.resource.DeviceResourceException : Unable to create resource FileImageDescriptor(location=class tableviewerexample.TableViewerExample, name=icons/unchecked.gif)
    at org.eclipse.jface.resource.ImageDescriptor.createR esource(ImageDescriptor.java:167)
    at org.eclipse.jface.resource.DeviceResourceManager.a llocate(DeviceResourceManager.java:56)
    at org.eclipse.jface.resource.AbstractResourceManager .create(AbstractResourceManager.java:88)
    at org.eclipse.jface.resource.ResourceManager.createI mageWithDefault(ResourceManager.java:192)
    at org.eclipse.jface.resource.ImageRegistry.get(Image Registry.java:211)
    at tableviewerexample.ExampleLabelProvider.getImage(E xampleLabelProvider.java:56)
    at tableviewerexample.ExampleLabelProvider.getColumnI mage(ExampleLabelProvider.java:88)
    at org.eclipse.jface.viewers.TableColumnViewerLabelPr ovider.update(TableColumnViewerLabelProvider.java: 71)
    at org.eclipse.jface.viewers.ViewerColumn.refresh(Vie werColumn.java:135)
    at org.eclipse.jface.viewers.AbstractTableViewer.doUp dateItem(AbstractTableViewer.java:386)
    at org.eclipse.jface.viewers.StructuredViewer$UpdateI temSafeRunnable.run(StructuredViewer.java:466)
    at org.eclipse.jface.util.SafeRunnable$3.run(SafeRunn able.java:154)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnab le.java:199)
    at org.eclipse.jface.viewers.StructuredViewer.updateI tem(StructuredViewer.java:2026)
    at org.eclipse.jface.viewers.AbstractTableViewer.crea teItem(AbstractTableViewer.java:264)
    at org.eclipse.jface.viewers.AbstractTableViewer.inte rnalRefreshAll(AbstractTableViewer.java:741)
    at org.eclipse.jface.viewers.AbstractTableViewer.inte rnalRefresh(AbstractTableViewer.java:633)
    at org.eclipse.jface.viewers.AbstractTableViewer.inte rnalRefresh(AbstractTableViewer.java:620)
    at org.eclipse.jface.viewers.AbstractTableViewer$2.ru n(AbstractTableViewer.java:576)
    at org.eclipse.jface.viewers.StructuredViewer.preserv ingSelection(StructuredViewer.java:1368)
    at org.eclipse.jface.viewers.StructuredViewer.preserv ingSelection(StructuredViewer.java:1330)
    at org.eclipse.jface.viewers.AbstractTableViewer.inpu tChanged(AbstractTableViewer.java:574)
    at org.eclipse.jface.viewers.ContentViewer.setInput(C ontentViewer.java:251)
    at org.eclipse.jface.viewers.StructuredViewer.setInpu t(StructuredViewer.java:1606)
    at tableviewerexample.TableViewerExample.addChildCont rols(TableViewerExample.java:155)
    at tableviewerexample.TableViewerExample.<init>(Table ViewerExample.java:46)
    at tableviewerexample.TableViewerExample.main(TableVi ewerExample.java:85)

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    icons/unchecked.gif
    Is this file there?

  5. #5
    janice is offline Member
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

Similar Threads

  1. [SOLVED] Load image into a JSP
    By jazz2k8 in forum New To Java
    Replies: 0
    Last Post: 05-08-2008, 11:33 AM
  2. Load URL that contains spaces?
    By barkster in forum Java Applets
    Replies: 0
    Last Post: 01-30-2008, 09:40 PM
  3. Replies: 0
    Last Post: 01-08-2008, 05:29 PM
  4. how to load a lot of files?
    By gabriel in forum Java Servlet
    Replies: 1
    Last Post: 08-07-2007, 06:04 PM
  5. Help with load image
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 07:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •