Swing inside JavaFX: Myth or …?

More than one year since my last post… what a shame! Despite this, I spent a lot of time working/playing with JavaFX.

My main focus was to deeply test JavaFX integration into existing Swing applications, which is currently pretty well handled by the JFXPanel. The main content that I tried to integrate into legacy Swing apps was the famous WebView node and I must admit this was really a pleasure to bring its functionalities into Swing apps. Of course, there are still some performance issues but this is really acceptable if you are not dealing with millions of data managed by a SVG rendering in html5 pages…

Now, what about the opposite? Swing legacy components inside brand new JavaFX applications? The SwingNode ? This is not available yet, even if it appears to be a priority in the “integration” map of JavaFX (extracted from JavaOne slides…). So, we have to be patient…

Since I really would like to see this integration ASAP, I bet that I could build my own SwingNode in less than a day… and I did :-).

Here is the result. This is a JavaFX application, with a SplitPane divided in two parts : a TreeView on the left hand side and a JTree on the right side, which is wrapped into my SwingNode component.

Quite impressive, no :-) ?! Mouse, drag and drop, keyboard…all works very well into this mixed application

If you’re still interested in knowing how it works, please add comments and I’ll add another post to demonstrate it and share the code with you.