简体   繁体   中英

Create a notification between methods in the same class

sorry to disturb you but it's been 2 days on th same problem and i don't find the solution so i come for your help . I think the solution is very simple but i can't find it .

Here it is, i am actually using a timer ( the one Java provides) and i want that at the end of my timer , one small notification or something like that tell it to my other method .

So here is my code :

internTimer = new Timer(true);

public void changeRound() {
    stopTimer();
    launchTimer();
    changeLayer();

}

public void changeLayer() {
    this.view.getRadarImage().removeLayer(this.view.getControlTowerLayer());
    this.view.setControlTowerLayer();

}


public void launchTimer() {
        internTimer.schedule(new TimerTask() {

            @Override
            public void run() {
                System.out.println("run");
            }
        }, (long) 10000);

}

public void stopTimer() {
    System.out.println("stopTimer");
    internTimer.cancel();
}

So as you can see all i need to do (as i think ) is just call something in my run method but i don't know what .

So i would like to call either method changeLayer() or changeRound() . but i can't cause i don't have access to my view in my thread.

So as you can see i'm very confused and if you could help me i would be very greatfull.

Thank you for your help :)

Finally i solved my problem, i jsu thad to use Plateform.runLater configuration ! If it can help someone , that's it !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM