2

I've been trying to create a .jar file using some .png images as custom icons for my buttons. In order to do this I want to use simple ResourceLoader class:

import java.awt.Image;
import java.awt.Toolkit;

public class ResourceLoader {
    static ResourceLoader rl = new ResourceLoader();

    public Image loadImage(String fileName) {
        return Toolkit.getDefaultToolkit()
            .getImage(rl.getClass().getResource("images/"+fileName));
    }
}

My problem, however, is that I can't access this class from my src package even though I added my res folder to the build path.enter image description here This picutre shows my current way of adding images - with a path in a constructor of an ImageIcon object. This, sadly, doesn't exports pictures permanently to .jar. What wrong am I doing? I'll be very grateful for any help from You!

Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
musztard2000
  • 127
  • 2
  • 14
  • Method loadImage is not static, so content assistant doesn't propose it. – agad Dec 19 '14 at 10:47
  • My mistake, I've changed it. But the problem hasn't gone. The `ResourceLoader` cannot be resolved as a variable... – musztard2000 Dec 19 '14 at 10:50
  • Your problem can be also the default package. http://stackoverflow.com/questions/2193226/how-to-import-a-class-from-default-package – Musich87 Dec 19 '14 at 10:51

0 Answers0