Java - Error on use of Timer

前端 未结 3 898
失恋的感觉
失恋的感觉 2021-01-24 17:46

So I have googled some minutes how to use the timer and found some helpfull threads here. But when I want to use the suggested code Eclipse shows me always an error.

         


        
相关标签:
3条回答
  • 2021-01-24 18:22

    Import javax.swing.Timer not java.util.Timer.

    Swing Timer has a constructor Timer(int , java.awt.event.ActionListener).

    0 讨论(0)
  • 2021-01-24 18:24

    take a look at your imports. Eclipse has auto imported java.util.Timer. Change that to javax.swing.Timer and you should be on your way.

    0 讨论(0)
  • 2021-01-24 18:43

    your import is wrong there correct that

    change

    java.util.Timer
    

    to

    javax.swing.Timer
    
    0 讨论(0)
提交回复
热议问题