Solved

Moving objects

Posted on 2007-03-27
3
201 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Server Faces parameter pass? 6 50
Java Options in Zimbra Server 2 54
Error trying to install RTMT Win7 5 60
reverse digits of a number using for loop 5 41
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

778 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