summaryrefslogtreecommitdiff
path: root/javax/swing/Timer.java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-06-24 05:32:26 +0000
committerMichael Koch <konqueror@gmx.de>2003-06-24 05:32:26 +0000
commit80876a88c68805b85cbb73614fa82fe00eaa5fc3 (patch)
treeed7dd27480d183188e3ca2f0d6e783e276fdd4b6 /javax/swing/Timer.java
parent74d673c5ee95254360457b3a7289171e14a69632 (diff)
downloadclasspath-80876a88c68805b85cbb73614fa82fe00eaa5fc3.tar.gz
2003-06-24 Michael Koch <konqueror@gmx.de>
* javax/swing/Timer.java (listenerList): New member variable. (actions): Removed. (addActionListener): Use listenerList. (removeActionListener): Likewise. (getListeners): New method. (getActionListeners): New method. (fireActionPerformed): Made protected. (fireActionPerformed): Reimplemented.
Diffstat (limited to 'javax/swing/Timer.java')
-rw-r--r--javax/swing/Timer.java38
1 files changed, 30 insertions, 8 deletions
diff --git a/javax/swing/Timer.java b/javax/swing/Timer.java
index 80eb13a1a..89df756ee 100644
--- a/javax/swing/Timer.java
+++ b/javax/swing/Timer.java
@@ -47,12 +47,13 @@ import javax.swing.event.EventListenerList;
public class Timer implements Serializable
{
+ protected EventListenerList listenerList = new EventListenerList();
+
int ticks;
static boolean verbose;
boolean running;
boolean repeat_ticks = true;
long interval, init_delay;
- Vector actions = new Vector();
class Waker extends Thread
{
@@ -86,23 +87,44 @@ public class Timer implements Serializable
public void addActionListener(ActionListener listener)
{
- actions.addElement(listener);
+ listenerList.add (ActionListener.class, listener);
}
+
public void removeActionListener(ActionListener listener)
{
- actions.removeElement(listener);
+ listenerList.remove (ActionListener.class, listener);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public EventListener[] getListeners (Class listenerType)
+ {
+ return listenerList.getListeners (listenerType);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public ActionListener[] getActionListeners ()
+ {
+ return (ActionListener[]) listenerList.getListeners (ActionListener.class);
}
- void fireActionPerformed()
+ protected void fireActionPerformed (ActionEvent event)
{
- for (int i=0;i<actions.size();i++)
+ ActionListener[] listeners = getActionListeners();
+
+ for (int i = 0; i < listeners.length; i++)
{
- ActionListener a = (ActionListener) actions.elementAt(i);
- a.actionPerformed(new ActionEvent(this, ticks, "Timer"));
+ listeners [i].actionPerformed (event);
}
}
-
+ void fireActionPerformed ()
+ {
+ fireActionPerformed (new ActionEvent (this, ticks, "Timer"));
+ }
public static void setLogTimers(boolean flag)
{