I created a string and i wanted it to appear to like 10 seconds and disappear again how can you do that using java ? Im using swing and i want apply this on a label Sorry for not specifying , i'm still new to java
If this is Swing, then use a Swing Timer. Set it to non-repeating, and call its constructor with the time in milliseconds that you'd like to show the String, here 10 x 1000. You could show the text in a JLabel by calling setText("your string") on the JLabel first and then call setText("") again on the JLabel from within the timer's ActionListener's actionPerformed method.
If this is not Swing, and even if it is, you need to provide a lot more detail for your problem to be fully solvable here.
精彩评论