Skip to content

Commit

Permalink
Added SystemTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
suncloudsmoon committed Jul 23, 2020
1 parent 0ce7bc5 commit 3fd11d6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Binary file added Traveler/res/Left Wanderer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Traveler/res/Right Wanderer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions Traveler/src/SystemTimer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Timer;

public class SystemTimer {

private static Timer tellTime = null;
private static boolean timerFinished = false;
private static int counter = 0;

public boolean getTimer() {
return timerFinished;
}

public boolean setTimer(long duration) {
ActionListener time = new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
counter++;
if (counter == duration) {
tellTime.stop();
timerFinished = true;
counter = 0;
}

}

};

if (counter == 0 && !timerFinished) {
timerFinished = false;
tellTime.setDelay(1000);
tellTime.start();
}

return timerFinished;
}
}

0 comments on commit 3fd11d6

Please sign in to comment.