向 Java Swing 容器添加动画/过渡
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11425274/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding animation/transitions to Java Swing containers
提问by Ankit
I just wanted to know if there are Java libraries that allow for smooth transitions between Java Swing Containers.
我只是想知道是否有允许在 Java Swing 容器之间平滑转换的 Java 库。
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.
假设我有一个带有单个 JFrame 的 Java GUI 应用程序。根据用户操作,我想更改 JFrame 中包含的 JPanel。现在,这是我可以做到的。然而,这种变化是瞬间的。我想做的是有一个缓慢的过渡/动画,这样用户的认知就不会太难。
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
假设我拥有的 JFrameframe
有 2 个按钮,我有两个 JPanelpanel1
和panel2
. 根据用户单击的按钮,我会将 替换frame
为panel1
或panel2
。但是,我希望这种变化是缓慢的/动画的(不管你怎么称呼它),fade-in
本身就是一种效果。所以我的问题是
Is there some Java library that allows for such transitions?
是否有一些 Java 库允许这种转换?
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).
如果没有,是否还有其他桌面开发语言可用于此类转换。我已经知道像 JQuery 这样的 Javascript 框架允许这样做。但是,我正在寻找桌面开发(如果不是 Java,那么其他任何东西也都可以)。
回答by Aurelien Ribon
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.
我也有同样的需求:应用程序中组件、面板和屏幕的平滑过渡和动画,以创建精美的 UI。由于我曾经为 java制作了一个动画引擎(Universal Tween Engine),我很快就设置了一个非常小且易于使用的库来在 Swing UI 中创建此类动画,即SlidingLayout 库。
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.
如果这就是您要找的,有一个专门的论坛,以防您需要帮助来设置项目中的库。
回答by MadProgrammer
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
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
我还建议查看http://filthyrichclients.org/以获得进一步的见解