Search in sources :

Example 11 with MouseMotionAdapter

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());
        }
    });
}
Also used : MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) Point(java.awt.Point)

Aggregations

MouseEvent (java.awt.event.MouseEvent)11 MouseMotionAdapter (java.awt.event.MouseMotionAdapter)11 MouseAdapter (java.awt.event.MouseAdapter)6 Alarm (com.intellij.util.Alarm)2 BorderLayout (java.awt.BorderLayout)2 Point (java.awt.Point)2 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 Ref (com.intellij.openapi.util.Ref)1 IdeFrame (com.intellij.openapi.wm.IdeFrame)1 PopupHandler (com.intellij.ui.PopupHandler)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 Tree (com.intellij.ui.treeStructure.Tree)1 FormBuilder (com.jgoodies.forms.builder.FormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseListener (java.awt.event.MouseListener)1 MouseMotionListener (java.awt.event.MouseMotionListener)1