want to drawLine additionally when Timer generates Events

后端 未结 1 597
再見小時候
再見小時候 2021-01-23 19:11

As I wrote in title, I want to drawLine additionally when Timer generates events.

Line will be draw like

first time;



        
相关标签:
1条回答
  • 2021-01-23 19:48

    You'll basically have to (not in order):

    • Build an event to happen on each tick of the timer
    • Pass it to a new timer (stopping the timer is in the documentation)
    • Set some sort of incrementing counter, either coordinate-based or tick-based
    • Override the paintComponent method in a component to draw the lines, based on the incrementing counter
    • From inside the event, call repaint() on your component (will happen on each timer tick)

    Work on each one of those tasks individually, and when you feel you've mastered each one, you can try putting them all together.

    0 讨论(0)
提交回复
热议问题