Solved

Moving objects

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 49
Facing this issue for maven proxy setting 2 26
add projects t working set in maven 2 37
web project error add remove 1 49
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

713 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