Reputation: 143
I'm developing a java game and I planned to do the UI with Swing, but I wanted to have animations between the menus, and for what I know, that would be hard to achieve.
I've been searching all day and saw that Java FX has transitions and transformations. I've been playing with it for a while, but I still don't know if I can do what I want.
Is it possible to achieve this effect? https://i.sstatic.net/zThXH.gif
Upvotes: 3
Views: 2648
Reputation: 7076
It is possible although not necessarily easy, however it'd certainly be much easier than doing it using swing. Check out this link , might answer some of your questions:
http://docs.oracle.com/javafx/2/animations/basics.htm#CJAFADFJ
Also this demo contains a lot of examples with their respective code, you can get an idea of whats possible from it:
http://download.oracle.com/otndocs/products/javafx/2.2/samples/Ensemble/index.html
Upvotes: 2
Reputation: 143
After a few failed tries, I decided to search for what is used in the gif I showed.
I eventually found it and it was exactly what I was searching.
github.com/AurelienRibon/sliding-layout
It's a very small library used for smooth animations between layouts of components. It's very easy to use!
In 20 minutes I was able to do this: imgflip.com/i/tmef
Upvotes: 4
Reputation: 159566
Your gif link appears to be a demo of clipped sliding transitions.
JavaFX is able to do this, though you will have to implement some of the logic yourself (e.g. you won't get all the functionality you desire without developing some custom animation and layout code).
JavaFX 2.x does not animate Swing based controls and windows. Because the basics of your UI are Swing based, you will only be able to do these kind animations on top of your Swing based UI by making the menus and dialogs being animated JavaFX only, and wrapping them in a JFXPanel so that they can be overlaid on top of your Swing UI. To, me that sounds like a tricky thing to accomplish well. You could use a Swing based animation library, but some of these like trident from insubstantial are just in maintenance mode at the moment.
Should you decide to go with a JavaFX solution:
A good starting point are the links Mr D provides in his answer.
Sai Pradeep Dandem has a nice overview of how to get this basic clipped sliding effect in his blog and I created a simple effect to slide in and out a side bar.
Full docking sliding in and out like your gif link demo would require a bit more work, but would be achievable. Likely, for a game you won't require all of the functionality displayed on the gif link demo. To replicate the gif link demos functionality you may want to also investigate fxexperience canned animations and the VFXWindows functionality added to jfxtras.
Upvotes: 3