• Post Reply Bookmark Topic Watch Topic
  • New Topic

the ball is not moved  RSS feed

 
theeradetch sillapacharoein
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





 
Carey Brown
Saloon Keeper
Posts: 3328
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a specific question you want help with?
 
Carey Brown
Saloon Keeper
Posts: 3328
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Fred Kleinschmidt
Bartender
Posts: 571
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, do not override the paint() method. you should override paintComponent() instead, and the first statement in that method should be
 
theeradetch sillapacharoein
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
not-move.jpg
[Thumbnail for not-move.jpg]
the ball can't be moved
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
theeradetch sillapacharoein
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)


sorry about that,

I will try back to deep study in each code.

thank you for your recommended
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!