Adding animation/transitions to Java Swing contain

2019-03-16 01:27发布

问题:

I just wanted to know if there are Java libraries that allow for smooth transitions between Java Swing Containers.

Suppose I have a Java GUI application with a single JFrame. Based upon user actions I would like to change the JPanel contained in my JFrame. Now, this I can do. However this change is instantaneous. What I would like to do is have a slow transition/animation so that it is not too hard on the users cognition.

Concrete Example:

Say the JFrame I have isframe having 2 buttons and I have two JPanel, panel1 and panel2. Depending on which button the user clicked, I would replace the frame with either panel1 or panel2. However I would like this change to be slow/animated (whatever you call it), a fade-in effect per se. So my question is

Is there some Java library that allows for such transitions?

If not, are there other desktop development language(s) that I can use for such transition. I already know of Javascript frameworks like JQuery that allow for this. But, I am looking for desktop development (if not Java then anything else is also fine).

回答1:

Something like that?

I had the same need: smooth transitions and animations of components, panels and screens in my app, to create a fancy UI. Since I once made an animation engine (Universal Tween Engine) for java, I quickly setup a very small and easy-to-use library to create such animations in swing UIs, the SlidingLayout library.

If that's what you're looking for, there is a dedicated forum in case you need help to setup the lib in your project.



回答2:

I can think of two animation libraries that would be capable of producing the effect you're after, but you'll have to do the work of getting the transition to actually work

  • TimingFramework
  • Trident

You should also check out:

http://weblogs.java.net/blog/kirillcool/archive/2007/04/who_doesnt_want.html

For a possible implementation

I'd also suggest checking out http://filthyrichclients.org/ for further insights