![]() |
![]() |
![]() |
![]() |
![]() |
|
Of course, you can make analogous changes to the locally defined mouse listener, producing a standalone mouse listener.
The following illustrates. Again, both the meter and the movie become
accessible via the value of the applet variable.
import java.awt.event.*;
public class MeterListener extends MouseAdapter {
MovieApplication applet;
public MeterListener (MovieApplication a) {
applet = a;
}
public void mouseClicked (MouseEvent e) {
int x = e.getX();
int y = e.getY();
int v =
(int) Math.round(applet.getMeter().getValueAtCoordinates (x, y)
/ 3.0
);
applet.getMovie().setScript(v);
applet.getMovie().setActing(v);
applet.getMovie().setDirection(v);
}
}