Handling the Event Dispatch Thread

前端 未结 4 1372
一个人的身影
一个人的身影 2021-01-01 06:22

I have a question about the \'Event Dispatch Thread\'. I have a Main class that is also a JFrame. It initialises the rest of the components in the code, some of them do not

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 07:20

    This is the way to go. The only thing you should be careful about is if a listener that you register with the Swing components will spawn a new Thread (often for carrying out some long computation). Such new threads will need to use invokeLater if they are to carry out GUI operations.

提交回复
热议问题