• Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving Icon  RSS feed

 
Fahmy Aziz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there. I'm trying to create a program which will generate a moving icon and allow the player to capture it. After capturing, it will be able to calculate time taken. I am very new to java so if somebody could point me in the right direction or have something similar to this it would really help. Thank you in advance.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't given a very full explanation of your problem, so it is a bit difficult to work out what you actually need.






But look in the java.lang.System class in the API to see whether there is anything there which might help with your timing.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I didn't notice you are a new member.


Welcome to the ranch . . . .
 
Fahmy Aziz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ritchie and thanks. Well the basic problem is this. I want to create a game which would allow me to calculate the time taken for a user to click on the icon I have generated and store it into a database.

The user would first input his/her name and age, click on the start button, see the generated icon in a new screen moving and try to capture (basically clicking) on the icon. This would result in the program storing the information (name, age, time taken to capture) in a database.

I would be very grateful if you could point me in the right direction, or perhaps have a similar example for me to get an idea on how it would be programmed in Java. Thank you in advance.
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, put the icon in a JLabel and give that JLabel a mouse listener to capture clicks.
Next, create a new thread with uses setLocation on the JLabel regularly (the smaller the interval, the faster it moves). You could also use a java.util.Timer for this. Don't forget to stop the thread / timer when the user clicks the label.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And for putting it into a database you'll probably need to look into using JDBC with an appropriate driver for your DBMS.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!