Skip to content

Commit 952a474

Browse files
hansonrhansonr
authored andcommitted
fixes Timer.prototype.restart()
1 parent ec547ef commit 952a474

File tree

1 file changed

+14
-4
lines changed
  • sources/net.sf.j2s.java.core/src/javax/swing

1 file changed

+14
-4
lines changed

sources/net.sf.j2s.java.core/src/javax/swing/Timer.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public void run() {
205205
if (logTimers) {
206206
System.out.println("Timer ringing: " + Timer.this);
207207
}
208+
int id = html5Id;
208209
if (notify.get()) {
209210
fireActionPerformed(new ActionEvent(Timer.this, 0, getActionCommand(),
210211
System.currentTimeMillis(), 0));
@@ -215,7 +216,7 @@ public void run() {
215216
if (isRepeats())
216217
dispatch(getDelay());
217218
else
218-
stop();
219+
stop(id);
219220
}
220221

221222
Timer getTimer() {
@@ -235,6 +236,7 @@ public void addActionListener(ActionListener listener) {
235236
listenerList.add(ActionListener.class, listener);
236237
}
237238

239+
238240
/**
239241
* Removes the specified action listener from the <code>Timer</code>.
240242
*
@@ -534,14 +536,22 @@ public boolean isRunning() {
534536
public void stop() {
535537
// getLock().lock();
536538
// try {
539+
stop(html5Id);
540+
// } finally {
541+
// getLock().unlock();
542+
// }
543+
}
544+
545+
protected void stop(int id) {
546+
if (id != html5Id)
547+
return;
537548
JSToolkit.killDispatched(html5Id);
538549
cancelNotify();
539550
repeats = false;
540551
timerQueue().remove(this);
541552
html5Id = Integer.MIN_VALUE;
542-
// } finally {
543-
// getLock().unlock();
544-
// }
553+
// TODO Auto-generated method stub
554+
545555
}
546556

547557
private ArrayList<Object> timerQueue() {

0 commit comments

Comments
 (0)