org.gnu.glib
Class Timer

java.lang.Object
  extended by org.gnu.glib.Timer

Deprecated. This class is part of the java-gnome 2.x family of libraries, which, due to their inefficiency and complexity, are no longer being maintained and have been abandoned by the java-gnome project. This class may have an equivalent in java-gnome 4.0, see org.gnome.glib.Timer. You should be aware that there is a considerably different API in the new library: the architecture is completely different and most notably internals are no longer exposed to public view.

public final class Timer
extends java.lang.Object

Timer: an object that executes a Fireable target object's fire method at a specified interval.

For example, here's how an application clock might be implemented, where the application passes in an org.gnu.gtk.Label object as its pane:

 private final Label clockPane = (Label) glade.getWidget("clockLabel");
 private Timer clock = new Timer(1000, // one second
         new Fireable() {
             public boolean fire() {
                 String dateStr = DateFormat.getDateInstance()
                         .format(new Date());
                 clockPane.setText(dateStr);
                 return true; // continue firing
             }
         });
 clock.start();
 

Note: a Timer generates events on the application's GUI event queue. It therefore is not accurate for short time periods. It also should only be used to directly fire short/fast methods. Longer methods need to be executed in a separate thread.

See Also:
Fireable

Constructor Summary
Timer(int interval, Fireable target)
          Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.
 
Method Summary
protected  void finalize()
          Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.
 int getInterval()
          Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.
 boolean isRunning()
          Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.
 void setInterval(int interval)
          Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.
 void start()
          Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.
 void stop()
          Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer(int interval,
             Fireable target)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.

Create a new Timer object.

Parameters:
interval - the time period between fire method executions, in thousandths of a second.
target - the object whose fire() method gets called after the specified time period elapses.
Throws:
java.lang.IllegalArgumentException - if less than one.
Method Detail

getInterval

public final int getInterval()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.

Returns the interval associated with this Timer.

Returns:
the time period between fire method executions, in thousandths of a second.

setInterval

public final void setInterval(int interval)
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.

Set the interval associated with this Timer.

Parameters:
interval - the time period between fire method executions, in thousandths of a second.
Throws:
java.lang.IllegalArgumentException - if less than one.

start

public final void start()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.

Start this timer object; that is, begin executing its fire method at its specified interval.


isRunning

public final boolean isRunning()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.

Returns whether this timer is running.

Returns:
true if this timer is currently running.

stop

public final void stop()
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.

Stop this timer object; that is, stop executing its fire method at its specified interval. This method does not need to be called if the fire method returned false.


finalize

protected final void finalize()
                       throws java.lang.Throwable
Deprecated. Superceeded by java-gnome 4.0; a method along these lines may well exist in the new bindings, but if it does it likely has a different name or signature due to the shift to an algorithmic mapping of the underlying native libraries.

Do not call this method; it's only purpose is to ensure that the timer is stopped before it is GC'd.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable