Time Delay using Thread.sleep() for paintComponent(Graphics g) not working as expected

后端 未结 2 1237
长情又很酷
长情又很酷 2021-01-15 11:32

I am making an Animated ProgressBar, in which i used multiple fillRect() method of class javax.swing.Graphics.
To put a delay after each rectan

2条回答
  •  轮回少年
    2021-01-15 11:51

    I really wouldn't do this. The Swing refresh thread isn't supposed to be used like this. You're much better off using another thread (perhaps using a TimerTask) and redrawing rectangles upon demand.

    Check out the Oracle ProgressBar tutorial for more info, code etc.

提交回复
热议问题