permaculture playing cards
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "moving circle problem!" Watch "moving circle problem!" New topic

moving circle problem!


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
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

Joined: Jan 07, 1999
Posts: 6920
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . 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.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: moving circle problem!
It's not a secret anymore!