use of java.awt.event.MouseMotionAdapter in project yyl_example by Relucent.
the class IGOBoard method addControlListener.
protected void addControlListener() {
this.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent event) {
int x = event.getX();
int y = event.getY();
if (((preMousePoint.x - x) > 2) || ((preMousePoint.x - x) < 2) && ((preMousePoint.y - y) > 2) || ((preMousePoint.y - y) < 2)) {
int cside = accountCellSide();
repaint(preMousePoint.x - cside, preMousePoint.y - cside, cside * 2, cside * 2);
preMousePoint = new Point(x, y);
}
}
});
addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent event) {
int event_x = event.getX();
int event_y = event.getY();
Point point = getToPoint(event_x, event_y);
if (point == null)
return;
switch(event.getButton()) {
case MouseEvent.BUTTON1:
{
gogo(point.y, point.x, YIN);
}
break;
case MouseEvent.BUTTON2:
{
gogo(point.y, point.x, VOID);
}
break;
case MouseEvent.BUTTON3:
{
gogo(point.y, point.x, YANG);
}
break;
default:
{
}
break;
}
repaint();
}
public void mouseExited(MouseEvent event) {
int cside = accountCellSide();
repaint(preMousePoint.x - cside, preMousePoint.y - cside, cside * 2, cside * 2);
preMousePoint = new Point(-255, -255);
repaint(event.getX() - cside, event.getY() - cside, cside * 2, cside * 2);
System.out.println(event.getX());
}
});
}
Aggregations