Problem with Java Swing Timer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yuzhengwen
    New Member
    • Dec 2014
    • 1

    Problem with Java Swing Timer

    I've been having a weird problem with my swing timer that I use in my game to count my points.
    Here's the code:
    The problem is that the thread does not run

    Code:
    	public void start() {
    		if (!running) {
    			t = new Thread(this); // t is the game thread with the game loop
    			t.start();
    			countPoints.start(); // is the timer, that repeats itself, waits  80miliseconds then add points
    			running = true;
    		}
    	}
    NOTE: I found that if I started the timer BEFORE t, it works, why?
Working...