Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24
  1. #21
    Cherno is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: If A Value of a Variable is increasing...

    What's a Robot class? How do i CHANGE the location of the cursor, since MouseEvent doesn't have a setMouseLocation() or whatever, I don't think at least...

    And with setting the time, I sort of get that. So:
    int mouseX = e.getX();
    double time = System.currentTimeMillis();
    double speed = time / mouseX;

    And I guess I would have to set something up to work out the change?

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default Re: If A Value of a Variable is increasing...

    What's a Robot class?
    Look in the API doc.
    Java Platform SE 6
    Classes are listed in lower left. Click on the class and its doc is displayed in the main window.

    double speed = time / mouseX;
    Not quite.
    You need the change in distance divided by the change in time to get pixels moved per milli-second
    double pixPerMS = (mouseX-oldMouseX)/(time-oldTime);

    You would have to use a more complicate equation to get the pixels moved if the y value also changes.

  3. #23
    Cherno is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: If A Value of a Variable is increasing...

    Thanks a lot for the Robot class, it does almost exactly what I want. I used the mouseMove method, and my code is as follows:

    if (mouseX > 599) {
    robot.mouseMove(1, 300);
    }

    Now the problem is that my mouse cursor location moves to 1, 300 on the screen, not inside my JFrame. How can I set that coordinate relative to the JFrame instead of the screen/monitor?

  4. #24
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: If A Value of a Variable is increasing...

    How can I set that coordinate relative to the JFrame instead of the screen/monitor?
    By subtracting the monitor coords of the frame or whatever you want the coordinates relative to.

    Component has a getLocationOnScreen().

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Colour increasing and retaining animation
    By monica in forum Java 2D
    Replies: 7
    Last Post: 05-15-2011, 04:56 PM
  2. Increasing/decreasing an int variable with boundrys
    By david522 in forum New To Java
    Replies: 5
    Last Post: 05-12-2011, 12:04 AM
  3. Increasing Java heap space
    By davetheant in forum New To Java
    Replies: 2
    Last Post: 02-03-2011, 02:24 AM
  4. increasing jvm heap space
    By kizyle502 in forum Advanced Java
    Replies: 1
    Last Post: 05-15-2010, 10:51 AM
  5. all maximal increasing subsequences
    By hassanJava in forum Advanced Java
    Replies: 3
    Last Post: 04-23-2008, 04:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •