several times change label text by clicking button in swing not work

前端 未结 2 1986
野的像风
野的像风 2021-01-26 07:55

I need to change jlabel.text several times by one click button in swing. In this code i need set label text to start before dowork() function and set to in progress in middle a

2条回答
  •  耶瑟儿~
    2021-01-26 08:07

    Never, NEVER use Thread.sleep, Thead.yield in the ETD

    Never, NEVER perform any blocking actions in the ETD, such as extended IO or data processing

    The reason that the label is not changing is because you are stalling/blocking the ETD, preventing it from processing any repaint requests.

    Check out Concurrency in Swing & The Event Dispatching Thread

提交回复
热议问题