Java Swing 元素转换
我正在尝试制作一个小型的非商业应用程序,并使其具有设计良好的界面,具有屏幕转换等功能。我在一个 JFrame 中的单独面板上拥有每个“屏幕”,并且希望能够在面板之间转换时平滑地滑动它们。有什么办法可以轻松地实现这一点吗?
I am trying to make a small non-commercial app and make it have a well designed interface, with screen transitions and such. I have every "screen" on separate panels in one JFrame and wish to be able to slide them smoothly when transitioning between panels. Is there any way to accomplish this somewhat easily?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于您尚未接受答案,我可以建议您使用 SlidingLayout 库吗?
这是一个非常小的库,其目的是在某些组件的两个布局之间创建平滑的过渡。因此,在两个屏幕之间进行转换非常容易。这是我刚刚制作的一个示例:
两个转换之间的差异取决于两行代码。您还可以通过在每个组件上应用不同的延迟来创建更奇特的过渡,因此它们不会同时出现,而是在它们之间存在一些时间变化。
我希望它对你有用:)
Since you did not accepted an answer yet, may I suggest you the SlidingLayout library?
It's a very small library which aim is to create smooth transitions between two layouts of some components. Thus, making a transition between two screens is very easy to do. Here's an example I just made:
The difference between the two transitions relies on two lines of code. You can also create more fancy transitions by applying a different delay on each component, so they appear not all at once but with some timing variations between them.
I hope it may be useful to you :)
这是一个典型的动画用例。最简单的方法是使用动画框架。我建议Trident
This is a typical animation use case. The easiest way is to use animation framework. I'd suggest Trident
我用 Java 编写了一个简单的程序来执行简单的幻灯片转换。您可以调整它来做其他事情(除了滑动)。
这是我的实现的链接:
http://www.java-forums.org/entry.php?b=1141
这是我编写的一个侦听器,用于检测屏幕上的手指拖动:
希望这会有所帮助。
I've written a simple program in Java to do simple slide Transitions. You can adapt it to do other things (than sliding).
Here is a link to my implementation:
http://www.java-forums.org/entry.php?b=1141
And here is a Listener I wrote to detect a finger drag on the screen:
Hope this helps.
或者,您可以使用这个简单的动画库 AnimaationClass 围绕其 x 和 y 轴移动 JComponent,然后隐藏/处置它们。
这提供了不错的(基本且流畅的)动画。
http://www.teknikindustries.com/downloads.html
它附带了一个 javadoc,如果您以某种方式不明白。
Alternatively, you could use this simple animation library, AnimaationClass, to move JComponents about their x and y axes then hide/dispose of them.
This offers decent (basic and smooth) animation.
http://www.teknikindustries.com/downloads.html
It comes with a javadoc if somehow you don't understand.