How to change a JLabel text for x Seconds
问题 I want to change the JLabel text for a short moment (there's a counter and if someone types in the wrong answer in a text field, I want to show a "wrong answer" instead of the counter. After a few seconds I want to show the counter again.) 回答1: For the fixed-delay execution of some code you want to use a timer object , in this case javax.swing.Timer. Here is a demo that applies to your situation: public static void main(String[] args) { SwingUtilities.invokeLater(()->{ JFrame frame = new