Click to See Complete Forum and Search --> : Newbie question on mouseEnter


NakedPanda
12-01-2003, 06:36 PM
Hello everyone
Im new here
Finally Ive found were all the cool coders hang out ;) . Im just learning java at the moment I dont know much just bits Ive picked up here and there. Im using the code below to make a penguin Baa when the mouse enters the java space currently (dont ask me why) but what I realy want to do is to be able to make it so that its only when the mouse goes over the penguins head that it baa's can anyone help?? In other words how do you specify that a mouseEnter event should trigger a sound only when the mouse is at a set coordinate or inbetween set co-ordinates???

the existsing code is

import java.applet.*;
import java.awt.*;

public class Penguine4 extends Applet {

Image coolImage;

public void init() {

System.out.println(">> init <<");
setBackground(Color.black);
coolImage = getImage(getCodeBase(), "yellow-eye-penqine.gif");
}

public boolean mouseEnter(Event evt, int x, int y) {
play(getCodeBase(), "ambientSheep.au");
return true;
}

public void start() {

System.out.println(">> start <<");


}



public void paint(Graphics g) {
System.out.println(">> paint <<");

g.drawImage(coolImage,100,100,this);
}

public void stop() {

System.out.println(">> stop <<");

}

public void destroy() {

System.out.println(">> destroy <<");

}

}


Thankyou for any help dudes

NP

ray326
12-01-2003, 10:01 PM
This is Java, not Javascript. Two entirely different things.

Khalid Ali
12-01-2003, 10:17 PM
you can use MouseAdapter class,it has methods such as mouseEntered which takes an argument of type MouseEvent

where in MouseEvent yo can get you X and Y points of wher ethe mouse is on the image...