Solved

Moving objects

Posted on 2007-03-27
3
198 Views
Last Modified: 2013-11-23
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
Comment
Question by:jmurguia
  • 2
3 Comments
 
LVL 13

Assisted Solution

by:kawas
kawas earned 250 total points
ID: 18800183
http://kawigi.yajags.com/animation/ has some source code with some good examples.
0
 
LVL 13

Assisted Solution

by:kawas
kawas earned 250 total points
ID: 18800187
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
 
LVL 30

Accepted Solution

by:
Mayank S earned 250 total points
ID: 18800219
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 80
Error with Java/Cache JDBC Classpath 2 30
maven project error 5 48
Windows 10 IE Certificate Issue 10 41
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now