473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Thread in Swing

How to implement animation in swing using thread. Whenever I try using Thread.sleep than it is not working
ex- if my pro have 3 sleep of 20 second than whole o/p is displaying after 60 second nothing b/w that.
I am changing value in a table or changing foreground of Label after clicking on a button
Dec 29 '08 #1
3 1777
JosAH
11,448 Expert 8TB
I bet you make the EDT (Event Dispatch Thread) sleep somewhere in a listener or in a method (in)directly called from there; right? The wrong thread sleeps then and it can't draw anything.

Make another thread sleep and use the SwingUtilities class to invoke some other method that calls the repaint() method at the end. The event thread will draw the stuff as soon as possible afterwards then.

kind regards,

Jos
Dec 29 '08 #2
Can you please give me a smallest example for that.
Jan 5 '09 #3
JosAH
11,448 Expert 8TB
@goelvivek
Google for "java animation" and you'll find numerous examples. They all use a separate thread that prepares the drawing parameters for the EDT thread to draw its image.

kind regards,

Jos
Jan 5 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ney André de Mello Zunino | last post by:
Hello. I have decided to look again at Java after a *really* long break. While browsing through the Swing tutorials , I noticed that the basic skeleton of the demo applications had something...
0
by: Buckaroo Banzai | last post by:
Hello, newbie here... I'm writing this program but when I click the start button which should initiate either the Hare or the Tortoise, it does not, this is the first time I use threads, so the...
8
by: =?Utf-8?B?T2xpdmVy?= | last post by:
Hey there, im quite new to C# GUI-Framework and got a question now. In Java its no problem todo cross-over Thread-calls. So i can change something in a Window from another thread. It seems C#...
1
by: GHKASHYAP | last post by:
Hi this is the exception i am getting when i am trying to run this application: Exception in thread "main" java.lang.NullPointerException thanks in advance.. package...
4
by: jmitch89 | last post by:
I don't why I get this error: Exception in thread "main" java.lang.NoClassDefFoundError The statement below works just fine: java -cp...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.