• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

speed is increasing unexpectedly

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi , it's budsy again . I am having a strange problem .I have designed a game. In this game i am using a timer . This timer is associated with an actionlistener . Whenever you click on the ball the ball starts moving up till it hits the ceiling and starts moving towards the floor . Now no where in the code am i reducing the interval because of which the speed will increase but now the strange thing is that
whenever i click on the ball, it starts moving up(like it's supposed to) but the speed also increases . Can somebody explain why ?





 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In which method are you constructing a Timer?

What happens each time that method runs?
 
budsy remo
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am constructing the timer in the mouseClicked() method . Maybe that's the problem that the previous thread is never stopped ?
In that method Timer notifies the class that is implementing the actionlistener after some intervals and that class's actionPerformed checks the boundaries(Y coordinate)
and accordingly increases or decrease the value.
 
budsy remo
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maybe that's the problem that the previous thread is never stopped ?


thanks a lot the problem has been resolved ,turns out that was the problem but just another question , is timer a thread ?
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

another question , is timer a thread ?


The answer to that is in the API. Make a habit of reading the API for any unfamiliar class, it'll serve you well.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic