Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2005

Tip: Looking for answers? Try searching our database.

animated buttons/status bar

Thread view: 
grahamo - 25 Mar 2005 15:47 GMT
Hi,

I need to put a little jazz into my swing gui. I would like to
represent running/inactive processes via some sort of animated
component. Ideally I'd like a green arrow that swirls around for the
active ones and a motionless red cross to indicate inactive ones.
What's the best approach to this in terms of components and threading?
I'm sure there's a standard approach as this has to have been done
thousands of times over.

thanks much

GrahamO
John McGrath - 28 Mar 2005 02:49 GMT
> I need to put a little jazz into my swing gui. I would like to
> represent running/inactive processes via some sort of animated
> component. Ideally I'd like a green arrow that swirls around for the
> active ones and a motionless red cross to indicate inactive ones.
> What's the best approach to this in terms of components and threading?

That depends on what you mean by "swirls".  Basically, you need to think
of the animation as a series of still frames (as in a frame of a movie,
not as in a window).  You need to:

1) Create member variables that store the state of the animation for a
given point in time.  This could be the position at which you are going to
draw something, an image index, parameters that control an
AffineTransform, something else, or a combination of any or all of the
above.

2) Write a method that will modify the state, advancing it to the next
frame.  If the state consists of a position, you might add some offset to
the position, or compute it using some other formula.  Or if using a
series of images, you would probably just increment the image index.
Obviously, this will depend on how you store that state.

3) Figure out how to draw the still frame for any given state.

4) Use a javax.swing.Timer to advance the state on a regular interval, or
possibly an irregular interval.  When the state changes, the component
should repaint() itself, or possibly just the portion of itself affected
by the change.

Signature

Regards,

John McGrath



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.