i'm trying to make a JFrame with 4 jlabels. So far no problems, but i want it to show the first only. 4 seconds later the second, and so on...

I know how to make the labels invisible and vasiable again, i just don't know about the time delay.

When searching the net a came across Thread.sleep();
But that showed my entire jframe after it went through all the sleep times, and didn't make the lables one by one visible.:sad:

Do you guys have any advice you can give me?

you can use Timer class and call method schedule().
Check API here

Thanks for your answer. It helped me for some other stuff i'm doing. But not for the labels thingy. The problem is when doing this

TimerTask task = new TimerTask ()  
               public void run ()  {  
                       Jlabel lblHallo = new JLabel();

i can't use


it won't add th label to my jframe
it works when not using TimerTask, but not within the RUN methode.
and yes i have this

Timer timer = new Timer () ; 
           timer.schedule ( task, 5000 ) ;//do after 5 sec

in my code

sorry how did u managed to solve the problem, i have same problem with images would u mind telling me. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.