jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes moving circle problem! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "moving circle problem!" Watch "moving circle problem!" New topic
Author

moving circle problem!

mskhawal
Greenhorn

Joined: Feb 16, 2001
Posts: 1
hello everybody,
i am new to java and i am trying to move a circle from one to another end in the applet horizontally using threads. The problem is that after repaint(), the paint() should be called. But how the position is increment ie., x-axis is the problem.
plz solve my problem
khawal
Daniel Searson
Ranch Hand

Joined: Dec 03, 2000
Posts: 83
I dont have the specifics of what you are doing but I would keep a couple of private variables x and y. x starts at 0 and y starts at getHeight() / 2.
In run(), increment x by 10 (or some other value), then call Thread.sleep() for a bit, then repeat (using while loop). Dont forget to call repaint() each time that the x value changes.
Hope that helps.
------------------
- Daniel


- Daniel
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"mskhawal",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: moving circle problem!