Java Timer not working

Posted by Jacob on Stack Overflow See other posts from Stack Overflow or by Jacob
Published on 2011-01-08T04:15:28Z Indexed on 2011/01/08 5:54 UTC
Read the original article Hit count: 198

Filed under:
|

I have an Image named worldImageToUse and I have a Timer that is supposed to toggle worldImageToUse between two images every 1 second. But it does not seem to work. Help Please?

public void startWorldImageFlash() {
        worldImageFlashTimer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                if(worldImageToUse == worldImage) setWorldImageBW();
                if(worldImageToUse == worldImageBW) setWorldImageColor();
            }
        };
        worldImageFlashTimer.scheduleAtFixedRate(task, 0, 1000);
    }


public void stopWorldImageFlash() {
        worldImageFlashTimer.cancel();
        setWorldImageColor();
    }

© Stack Overflow or respective owner

Related posts about java

Related posts about timer