0 Replies - 452 Views - Last Post: 01 July 2013 - 03:02 PM Rate Topic: -----

#1 guntanis  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 20-June 13

robot loop for an animation;

Posted 01 July 2013 - 03:02 PM

im tring to animate motion of the mouse from 1 button to another in an array with the class robot.
here are de two methods I used:
public void optimusprime(int row, int column, JButton current) throws InterruptedException {
        Point p;
        Point p2;
        double x;
        double y;
        double x2;
        double y2;
        double conx = 0;
        double m;
        double b;
        double cony;
        p = current.getLocationOnScreen();

        x = (int) p.getX() + 30.5;
        y = (int) p.getY() + 30.5;

        optimus((int) x, (int) y);




        p2 = mesa[row][column].getLocationOnScreen();
        x2 = (int) p2.getX() + 30.5;
        y2 = (int) p2.getY() + 30.5;

        m = (y2 - y) / (x2 - x);
        b = y2 - (m * x2);
        while (conx != x2) {

            conx = x;
            cony = (m * conx) + b;
            optimus((int) conx, (int) cony);
            conx++;
            Thread.sleep(5);
        }

    }

    public void optimus(int x, int y) {
        try {


            Robot robot = new Robot();
            robot.mouseMove(x, y);
        } catch (AWTException e) {
        }
    }

can any 1 help me here or at least give a recommendation?. got stock in an endless loop(had to shutdown the pc) and it didnt work at all; Im new to java it could be several stupid mistakes :/;
i can post all my code if necessary;

Is This A Good Question/Topic? 0
  • +

Page 1 of 1