Re: Easily implementing a Timer
"DaveN" <DaveN@DaveN.COM> writes:
void MainFunction()
In Java, ?function? usually does not have the implied meaning.
Class declarations contain /method/ declarations.
if(UserMakesStartSelection == 1)
The user should not be able to create multiple timers in
parallel this way. Also, user events often are transported as
invocations, so often one will not use ?if?, but an event
handling method.
void TimerFunctionToCall()
To be able to designate a method as an argument value (as
above), it needs to be wrapped in some object. There are no
method references in Java - only object references. And method
names usually start with a lower-case letter.
All the examples I've seen seem to have these functions all
wrapped together in a class which makes it difficult to
understand and follow. Like I say it's probably my lack of OOP
but if anyone can help to clear the muddy waters I would
appreciate it.
You do not need to learn OOP (as in Smalltalk), it is
sufficient to learn Java. Possibly, start with the
fundamentals and then read approach more complicated topics
later.
1st step: Learn about invocations of operations (methods)
including argument passing, learn to use standard types
(primitive types, classes and interfaces including standard
methods), learn to read JavaDocs, learn the terms. take some
time for exercises. Take care to learn the difference between
static and non-static operations (AKA methods).
2nd step: Learn how to write and use declarations for
variables, methods, classes, interfaces, and JavaDoc. Do more
exercises.
3rd step: Learn fundamentals of Swing (like the EDT and the
delegation event model) and something about threads. Learn
some common patterns, like ?Observer?.