Updating a JLabel within a JFrame

后端 未结 1 1702
青春惊慌失措
青春惊慌失措 2021-01-17 00:13

I\'ve been searching around this site and the internet for hours trying to figure out how to fix this problem. I\'m creating a game and it\'s my first time using graphics. I

相关标签:
1条回答
  • 2021-01-17 00:25

    Don't sleep or otherwise block on the AWT Event Dispatch Thread (EDT).

    Use javax.swing.Timer instead. Note: not any other class of the same name in a different package.

                javax.swing.Timer timer =
                    new javax.swing.Timer(2500, event -> {
                        testing.setText("hi");
                    });
                timer.setRepeats(false);
                timer.start();
    
    0 讨论(0)
提交回复
热议问题