Results 1 to 2 of 2
  1. #1
    MartinBenes71 is offline Member
    Join Date
    Jan 2010
    Rep Power

    Default button that runs away from the mouse cursor

    Hey guys, I need some help.

    If you can maybe direct me in the right direction or let me know how to do it, I want to make a button, run away from the mouse cursor basicially. Its connected to my previous post about the button game. I got that to work, but this is the final piece.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    It might help to be precise about "run away".

    Your last post talked about the buttons being laid out in a grid. Is the moving button supposed to be on this grid? Is its movement constrained by the grid and/or empty spaces?

    In any case you could use a mouse motion listener which will report the position of the mouse as it moves. Use this position and whatever rules constrain the moving button to decide if the button should move and, if it should, move it.

Similar Threads

  1. Mouse Listener for mouse floating over object?
    By Krooger in forum AWT / Swing
    Replies: 1
    Last Post: 11-18-2009, 04:34 AM
  2. change the mouse cursor - crosshair cursor
    By cassysumandak in forum New To Java
    Replies: 1
    Last Post: 09-28-2009, 01:57 AM
  3. Show image on glasspane while mouse button is down
    By zweibieren in forum AWT / Swing
    Replies: 10
    Last Post: 09-12-2009, 06:29 AM
  4. [SOLVED] App runs only in IDE
    By hannehomuth in forum Advanced Java
    Replies: 4
    Last Post: 07-15-2009, 06:41 PM
  5. Hovering mouse over a button and painting
    By gtraylo in forum AWT / Swing
    Replies: 2
    Last Post: 04-24-2008, 09:33 AM

Posting Permissions

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