APL/APL2.1/TP11/Rectangle/Observer.java

26 lines
832 B
Java
Raw Normal View History

2022-04-12 17:16:22 +02:00
public class Observer implements MouseMotionListener, MouseListener {
public Observer() {}
void mouseClicked(MouseEvent evenement) {}
void mouseEntered(MouseEvent evenement) {}
void mouseExited(MouseEvent evenement) {}
void mouseMoved(MouseEvent evenement) {}
void mousePressed(MouseEvent evenement) {
Rectangle rect = (Rectangle)evenement.getSource();
rect.SetX(evenement.getX());
rect.SetY(evenement.getY());
rect.ShouldDraw(true);
}
void mouseReleased(MouseEvent evenement) {
Rectangle rect = (Rectangle)evenement.getSource();
rect.ShouldDraw(false);
}
void mouseDragged(MouseEvent evenement) {
Rectangle rect = (Rectangle)evenement.getSource();
rect.SetSX(evenement.getX());
rect.SetSY(evenement.getY());
}
}