• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Moving objects

How would I code to move a circle,triangle internal to my GUI, all by itself?

Also, how would I code a key on the keyboard to make that object move?
0
jmurguia
Asked:
jmurguia
  • 2
3 Solutions
 
kawasCommented:
http://kawigi.yajags.com/animation/ has some source code with some good examples.
0
 
kawasCommented:
basically, you create a shape and using a timer, move the shape when the time is right. As for the keyboard, add a listener to perform whatever action you wish when you press the key
0
 
Mayank SAssociate Director - Product EngineeringCommented:
If you want to move the object upon key press you will need to do that in the keyPress event - you'll need a KeyListener for that. I guess the timer is not needed in that case, if you want to do it only on key-press but not on regular intervals - you will get some sample code here:

http://forum.java.sun.com/thread.jspa?threadID=5146827&messageID=9546374

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now