Adding my own icon

Developers
Una
2008-01-22
2012-08-29
  • Una

    Una - 2008-01-22

    Hi i want to add my own icon to the project but it keeps throwing this error:

    Exception in thread "main" java.lang.IllegalArgumentException: Argument cannot be null
    at org.eclipse.swt.SWT.error(SWT.java:3358)
    at org.eclipse.swt.SWT.error(SWT.java:3297)
    at org.eclipse.swt.SWT.error(SWT.java:3268)
    at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:125)
    at org.eclipse.swt.graphics.ImageDataLoader.load(ImageDataLoader.java:22)
    at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:328)
    at org.eclipse.swt.graphics.Image.<init>(Image.java:545)
    at net.sourceforge.rssowl.util.shop.PaintShop.loadImage(PaintShop.java:618)
    at net.sourceforge.rssowl.util.shop.PaintShop.loadImage(PaintShop.java:595)
    at net.sourceforge.rssowl.controller.RSSOwlLoader.<init>(RSSOwlLoader.java:94)
    at net.sourceforge.rssowl.controller.RSSOwlLoader.main(RSSOwlLoader.java:126)

    I have added the new icon to the res.jar file, created it in PaintShop as a public static Image, initialized it:
    public static Image iconFid;

             iconFid = loadImage(&quot;/img/icons/fid_icon.GIF&quot;);
    

    I then call the image in another class:

             loginItem.setImage(PaintShop.loadImage(toolImgPath + &quot;fid_icon.GIF&quot;, true));
    

    Can you please tell me if there is a step i am missing. I have tried both initializing it on startup and without initializing it loading from the class.

    Any help would be appreciated

     
    • Benjamin Pasero

      Benjamin Pasero - 2008-01-22

      Why don't you use the static image directly but load it again?

       
      • Una

        Una - 2008-01-22

        I have tried this.

        It seems that when i add my own icon to the res.jar file in the img/icons folder it is causing an error. I have been trying for most of today to change just one icon!! When i changed the path of another icon to that of mine the error occurred - when i changed it back to the first icon which had previously worked the error is still there.

        I apologise i am only beginning to understand the source code but i cant see why my code would break the whole application.

        setTitleImage(PaintShop.loadImage("/img/icons/baseauth.gif"));

        was changed to :

        setTitleImage(PaintShop.loadImage("/img/icons/fid_icon.gif"));

         
    • Benjamin Pasero

      Benjamin Pasero - 2008-01-23

      Hm, the problem must be elsewhere then. I guess you are developing with an IDE like Eclipse? If you follow these steps it should work:

      • make sure res.jar is on the classpath so that the image can be loaded
      • add your icon to res.jar, lets say img/icons/foo.gif
      • modify PaintShop by adding a new static field:

      public static Image iconFoo;

      • in PaintShop.initIcons() add

      iconFoo= loadImage("/img/icons/foo.gif");

      • From where you want to use the Image, directly use it by calling PaintShop.iconFoo, dont load the image again

      Note that when you run RSSOwl outside the IDE the res.jar is extracted into the rssowl.jar using the given build.xml. Just in case you wonder why the res.jar is not present in the file system.

      Hope that helps,
      Ben

       
      • Una

        Una - 2008-01-25

        Ben,

        Thank you so much for your replies. The above steps you have described are what i had been trying. I think my problem was with the jar file itself.

        Una

         

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks