You are not calling move() anywhere, so it's not moving.
The best way to do this is to create a method that will move all the balls and then call repaint(). Then create a swing.Timer object that calls that method. Experiment with the delay that you pass to the Timer.
Carey Brown wrote:Sorry, missed your subject heading.
You are not calling move() anywhere, so it's not moving.
The best way to do this is to create a method that will move all the balls and then call repaint(). Then create a swing.Timer object that calls that method. Experiment with the delay that you pass to the Timer.
Sorry about that,
I already created the method but it not moved as attached file.
plese,see the code
acctually, I just started with new lesson about GUI and method. i copy this code from my book and so it not working as described
You got that code from a book!? What book was that?
And does your latest post mean that you included the advice that Carey Brown in your new version of your code? If not, then why not?
(Also, showing us a picture of some circles isn't really evidence that the circles aren't moving when your code runs. It's only evidence that the code can display the circles successfully.)
Paul Clapham wrote:You got that code from a book!? What book was that?
And does your latest post mean that you included the advice that Carey Brown in your new version of your code? If not, then why not?
(Also, showing us a picture of some circles isn't really evidence that the circles aren't moving when your code runs. It's only evidence that the code can display the circles successfully.)
No, seriously, if you really got that code from a book which claims to teach you Java, then it isn't a very good book. Don't deep-study that code because it isn't good. Instead, I would suggest getting a different book, or even just start with Oracle's Java tutorials.