-4

I have this function which I want to call with this: MouseHover("btnAttackHover.png",btnAttack);

Image btnAttack;
 public void MouseHover(String i,Image e){
            ImageIcon btn = new ImageIcon("src/images/btn/"+i);
            e = btn.getImage();
    }

When I call it,this should change the image and draw this:

g.drawImage(btnAttack,100,100,100,100,null);

But the e = btn.getImage(); doesn't work.

How can I pass the Image Object "btnAttack"?

Aaron
  • 47
  • 4
  • 1
    Possible duplicate of [Is Java “pass-by-reference” or “pass-by-value”?](http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value) – Andreas Apr 10 '16 at 15:00

1 Answers1

0

Try something like this:

    public Image MouseHover(String i){
        ImageIcon btn = new ImageIcon("src/images/btn/"+i);
       Image  e = btn.getImage();
     return e;
     }

Now if you want to draw image just do this:

  g.drawImage(g.MouseHover(..),100,100,100,100,null);
Abdelhak
  • 8,299
  • 4
  • 22
  • 36