Login  Register

Delay only 1 class method, not whole program

Posted by bchinfosieeuw on Jul 31, 2018; 12:00am
URL: https://forum.jogamp.org/Delay-only-1-class-method-not-whole-program-tp4039081.html

How do I start the behavior of a certain method (possibly in another class) later than another method? I do not want to let the whole program sleep. Code I have now:

static Timer timer_1;
public void actionPerformed(ActionEvent e ) {

        if (e.getSource()==go){
                if (!timer.isRunning()) {
                        timer.start();
                       
                }
       
        //timer_1 = new Timer(0, new TimerAction1());
        TimerAction1 ta1 = new TimerAction1();
        ta1.fen();
        //timer_1 = new Timer(0, ta1);
        }
       
}

static class TimerAction1 implements ActionListener
{
        TimerAction1(){
        }
        public void actionPerformed(ActionEvent e){
        }
 

        void fen() {
       
        System.out.println("Fen method");
        }
}

I need to use the swing timer probably, but I do not know how to do so.