• Post Reply Bookmark Topic Watch Topic
  • New Topic

Events and Timer help  RSS feed

 
Andy Totes
Greenhorn
Posts: 3
Java Mac Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys, brand new here!
Im looking at increasing my understanding of event driven programming especially in relation to swing timers and the like.
Are there any really good tutorials out there? Ive read a heap of docs and got a couple of books on Java out from uni but it appears time has moved on from Java2 and thus the information isn't current ;)

Any help would be great, Im thinking a simple traffic light app based on swing would be sufficient but I just can't find anything

Very grateful!
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Andy,

Swing Timers are very easy to use. Have a look at the Oracle tutorial:

http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html

Greetz,
Piet
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
As PS implies, Timers are reasonably easy to use. Beware: there are three classes in the JavaSE API called Timer (or there were three the last time I looked).

I think this discussion might fit better in our GUIs forum, so I shall move it.
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome to the Ranch
(...) Beware: there are three classes in the JavaSE API called Timer (or there were three the last time I looked). (...)

Well, you will find out soon enough when you picked the wrong one.

But indeed: NetBeans IDE has the nasty habit of offering the three choices, with the
Java.util.Timer as the first option. So in that case, don't click 'on the auto pilot', since
in nearly all other cases you can simply click on the first option.

Greetz,
Piet
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there is a com.sun.something.Timer, then Eclipse will go one better and offer that as the first option Click that on autopilot and you really have got the wrong import.
 
Andy Totes
Greenhorn
Posts: 3
Java Mac Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tips guys, Im doing an assignment at uni and I had myself convinced it was my timer that was playing up.
Turns out it was more the events handling side of my code! All is working as expected now!
p.s. friendliest forum ever! may spark my return to forums!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!