Inserting a timer in a java game

need help in using timers in java using JCreator..

Page 1 of 1

9 Replies - 8294 Views - Last Post: 08 March 2010 - 03:59 PM Rate Topic: -----

#1 ryomadarktezuka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 02-August 09

Inserting a timer in a java game

Posted 08 March 2010 - 03:07 PM

Just wanna ask how can I include a timer in my java game.. for example

the timer is set to 10 seconds.. and after that the message dialog box will prompt you that it's already 10 secs.. please I really need this timer..

thanks in advance.. :stupid:
Is This A Good Question/Topic? 0
  • +

Replies To: Inserting a timer in a java game

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10567
  • View blog
  • Posts: 39,113
  • Joined: 27-December 08

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:11 PM

You should check out the Swing Timer class and the ActionListener interface, as that is the tool used to "listen" to the Timer's "ticks."

If you need more help, feel free to post. Remember to include your good faith efforts. Good luck! :)
Was This Post Helpful? 0
  • +
  • -

#3 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:14 PM

I actually wrote a program, that every ten seconds, displays a dialog box stating 10 seconds has elapsed. However, it is an applet, but I hope you find it helpful.

http://www.dreaminco...snippet4709.htm
Was This Post Helpful? 0
  • +
  • -

#4 ryomadarktezuka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 02-August 09

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:28 PM

thanks for the infos guys.. :yes:

View PostDogstopper, on 08 March 2010 - 02:14 PM, said:

I actually wrote a program, that every ten seconds, displays a dialog box stating 10 seconds has elapsed. However, it is an applet, but I hope you find it helpful.

http://www.dreaminco...snippet4709.htm



Don't worry I know how to use an applet.. and thanks for sharing.. :)

View Postmacosxnerd101, on 08 March 2010 - 02:11 PM, said:

You should check out the Swing Timer class and the ActionListener interface, as that is the tool used to "listen" to the Timer's "ticks."

If you need more help, feel free to post. Remember to include your good faith efforts. Good luck! :)



thanks for the site!!! I hope JCreator have this methods too... (>_<)
Was This Post Helpful? 0
  • +
  • -

#5 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:29 PM

If its Java, it should have those methods...JCreator is merely your Editor.
Was This Post Helpful? 0
  • +
  • -

#6 ryomadarktezuka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 02-August 09

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:41 PM

View PostDogstopper, on 08 March 2010 - 02:29 PM, said:

If its Java, it should have those methods...JCreator is merely your Editor.



can I also put a timer in a JFrame..?? because my game is done in a Frame..(actually it isn't even done..) (-_-;)
Was This Post Helpful? 0
  • +
  • -

#7 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10567
  • View blog
  • Posts: 39,113
  • Joined: 27-December 08

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:43 PM

As Dogstopper said, JCreator as well as other IDEs like NetBeans, Eclipse, BlueJ, etc. are only tools to help you write your code. In the end, your source code is still compiled into byte code, which is still interpereted by the JVM. So as long as you have a fairly current version of the JDK installed and your IDE configured correctly, you should be fine.

Edit: Yes, you can include a Swing Timer with any GUI component, or even in a non-GUI environment or class.

This post has been edited by macosxnerd101: 08 March 2010 - 03:44 PM

Was This Post Helpful? 1
  • +
  • -

#8 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:43 PM

It can be done in any class that implements ActionListener (including JFrame, JApplet, JPanel)...

http://www.dreaminco...&showentry=2094
Was This Post Helpful? 0
  • +
  • -

#9 ryomadarktezuka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 02-August 09

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:54 PM

The problem is .. I think we're not using the current version of JCreator.. but then I'll use the ideas from the sites and codes you gave me guys..thanks for the help ^^
Was This Post Helpful? 0
  • +
  • -

#10 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: Inserting a timer in a java game

Posted 08 March 2010 - 03:59 PM

JCreator isn't really a factor here. The only thing that matters is that your JDK installation is up to date
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1