I have a project written using Swing, and I want to make it more smoothly (like JavaFX is) by adding animation to some components(JButton, JScrollPane, JSplitPane) using javax.swing.Timer. UPD: That is not a game. I want to use the Timer for short animations like mouseHover events or dropdown, or scroll. But the problem is, a lot of Timer objects should be created. Question: What action does it perform for JVM? I would start and stop a lot of Timers during app session.
Animation in Swing
java;swing;animation
Yes if you wanna do the animation yourself, javax.swing.Timer is your best option. It is lightweight and guarantees your code executes on the EDT thread. If you venture into the depths of swing components like JScrollPane you might encounter javax.swing.Timer being used for things like auto scrolling during drag and drop etc. In short animation in swing is quite possible but rare in standard components. Just keep your redraw area to the minimum and repaint wisely. I would advocate looking into timing framework though. 