This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
HI All,
I have a requirement where in a JComponent like JButton, JLabel, JTextArea, etc., should me moved from given (x,y) location to another given (x,y) location within a given specific time in milli seconds.
Inputs given are:
1. Start (x,y)
2. End (x,y)
3. Time to travel from start (x,y) to end (x,y)
Say, if i have given the time as 4000ms, the component should travel from start (x,y) to end (x,y) in 4000ms (4 secs).
Hi,
Thanks for the replies and sorry that I dint post what I have tried on till now.
Here is the piece of code what I am doing right now.
The 'direction' refers to which direction is the component coming from.
For direction, I have done the below calculation so that the component will start from the location which will be set by the below calculations.
I am doing this entire thing in Swing Timer itself but I am not getting the exact calculation.
I mean the component is not coming to the center of the Panel after its transition according to the transition time.
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
you really need to post a working program that demonstrates the problem.
just have it move from a to b in x time, forget directions.
if you get the first part working OK, then add a direction etc
doing it this way, you might find the problem yourself, but if not, you can
post the code with the info that it worked OK until I added this...