Make text appear briefly in a JPanel

Posted by Roo on Stack Overflow See other posts from Stack Overflow or by Roo
Published on 2011-01-02T13:06:30Z Indexed on 2011/01/02 13:53 UTC
Read the original article Hit count: 173

Filed under:
|
|

Hi,

I am trying to make text appear briefly before it disappears. It would be along the lines of
1) Set color to black
2) wait x amount of seconds
3) set color to background color

The method I call is repaint(), which then calls paintComponent(Graphics painter). repaint() is called only if I press the space-bar.

I thought of trying repaint();Thread.sleep(1000);repaint(); (I do catch the Interrupt exception, just not shown), but it only calls paintComponent once per space-bar .

Is there an easy way to do this or is this something that is a bit challenging?

© Stack Overflow or respective owner

Related posts about java

Related posts about swing