Lag spike when moving player

后端 未结 2 1700
抹茶落季
抹茶落季 2021-01-16 09:48

The player is a panel, and it is getting removed, its position changed, and then re-added to another panel (which is what contains this method) which is drawn to the main fr

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-16 10:30

    AttentionedPlayer.movePlayer(); seems to be an intensive operation, and you execute it from within EDT (the GUI thread). Instead, execute it from within a new thread or a SwingWorker.

    Read this answer to know more about SwingWorker.

提交回复
热议问题