-1

I am working on a java code and my image is not shown in the final run. I put it in an entity and I also handed the entity over to the entity manager. Eclipse is not showing me any problem, but when I go to run I can not see my image only the background I did wrote before.

Any suggestions on how to fix it?

The following is the part for my code:

private void gorilla() {
    Entity gorilla1 = new Entity("gorilla1");
    gorilla1.setPosition(new Vector2f(590, 190));
    try {
        gorilla1.addComponent(new ImageRenderComponent(new Image("assets/gorillas.gorillas/gorilla_right.png")));
    } catch (SlickException e) {
        System.err.println("Cannot find file gorilla_right.png!");
        e.printStackTrace();
    }

    entityManager.addEntity(stateID, gorilla1);   
}
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
Stef
  • 33
  • 6
  • run it in console and post the result. apart from that, i'd say you have stored the image in the wrong directory, but we'll see after the result from the console –  Mar 15 '15 at 19:10
  • Why are you *assuming* that the exception means that the file couldn't be found? What does the stack trace show? Which `Image` class is this? – Jon Skeet Mar 15 '15 at 19:11
  • Look at this http://stackoverflow.com/questions/8333802/displaying-an-image-in-java-swing , maybe it will help you. – alnasfire Mar 15 '15 at 19:40

0 Answers0