Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

the ball is not moved  RSS feed

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





 
Saloon Keeper
Posts: 4736
52
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: 4736
52
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.
 
Bartender
Posts: 620
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
 
Sheriff
Posts: 23692
50
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: 23692
50
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!