Thread: Timer

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    43
    Rep Power
    4

    Timer


    I have a object moving according to a certain algorithm and I want to make it move a different way every 5 seconds. How do i do that using the timer?
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    Originally Posted by lisa92
    I have a object moving according to a certain algorithm and I want to make it move a different way every 5 seconds. How do i do that using the timer?
    You would attach an ActionListener to the timer that fires once every 5 seconds. Each time actionPerformed is called you would modify a variable that makes your object move differently.

IMN logo majestic logo threadwatch logo seochat tools logo