Originally posted by Eamon Williams:
Also, many counter code examples I have found are applets, which are no good.
Also, is it possible to create a seperate Counter class that will handle the functionality of the timer and update the Jlabel present on the main form class? I am trying to keep as much code out of the main form as possible as it's getting quite big.
Any help gratefully appreciated.
The fact that a particular GUI example is presented in applet form shouldn't be a problem at all. There's really nothing magic about applets. As long as you know that the container will call init(), then start(), it's very easy to adapt an applet example to be used in other contexts.
As to creating a separate counter component -- yes, absolutely. You could just extend JLabel with an appropriate constructor, a
Thread or Swing Timer member, and a few extra methods for starting, stopping, and resetting.