aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes speed is increasing unexpectedly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "speed is increasing unexpectedly" Watch "speed is increasing unexpectedly" New topic
Author

speed is increasing unexpectedly

budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
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 ?





Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5

In which method are you constructing a Timer?

What happens each time that method runs?


luck, db
There are no new questions, but there may be new answers.
budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
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

Joined: Sep 20, 2008
Posts: 103
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

Joined: May 03, 2008
Posts: 4529
    
    5

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: speed is increasing unexpectedly