5

I have searched stackoverflow extensively for help on this topic, but the Q&As I found are old and the answers have changed for the current version of the JDK (I'm currently using 7u51).

Note that I was never SUPER proficient in Swing to begin with, but I believe I understand the fundamentals. (I've always been more focused on the meat inside an app, not the GUI).

I'm trying to work with a third party library. The third party library requires that it's components use JFrame.

Therefore, I'm trying to see how I would embed a JFrame into my JavaFX application. There was an old answer about doing something with javafx.ext.swing, but that's no longer included in JavaFX.

Help?

==========

I should also add: I think Java 8, which is currently beta, will support what I need based on this: http://docs.oracle.com/javafx/8/embed_swing/jfxpub-embed_swing.htm , but I need to see if there is a way to do this without relying on a beta product.

adeena
  • 4,027
  • 15
  • 40
  • 52
  • This doesn't work anymore? http://stackoverflow.com/questions/437413/how-can-jframes-be-used-inside-of-javafx?rq=1 – Aaron Digulla Feb 07 '14 at 13:49
  • This should help: http://stackoverflow.com/questions/6157277/how-to-wrap-a-swing-component-in-a-javafx-2-0-application?rq=1 – Aaron Digulla Feb 07 '14 at 13:51
  • Correct about that first comment... javafx.ext.swing* is gone... – adeena Feb 07 '14 at 14:00
  • As for the second link... I came across that, too, and have been through the links within there (and another level, too)... and am finding either references back to the javafx.ext.swing again, or 3rd party libraries which are difficult to justify. This whole exercise is to prove that a particular 3rd party library is useful to my team... using another unknown 3rd party library to do that is not helpful. – adeena Feb 07 '14 at 14:06
  • This is still a duplicate. You will probably have to analyze the license and code of ThingsFX and use it to embed `JFrame`s into your JavaFX app. – Aaron Digulla Feb 07 '14 at 14:18
  • I'm not sure that ThingsFX will work given the licensing situation (and the lack of documentation will prevent me from testing it at work - I'd have to do that at home). My best bet might be to wait for Java8 (or work with the beta in anticipation). – adeena Feb 07 '14 at 14:50
  • 1
    Even if the JDK is still beta, the functionality of the embedded Swing in JavaFX applications will not be removed. This has been announced by Oracle to its users, and is almost in the final stage now. It is true that nobody can say that it will NEVER be removed in the future, but I can tell you that it probably will not be. Be reassured to use JDK 8. You can also search on web for news of JavaFX 8 and JavaFX 8 Roadmap. Good luck on your projects. :) – Loa Feb 07 '14 at 16:36

3 Answers3

2
  1. Create a SwingNode s
  2. Create a JComponent c
  3. Call s.setContent(c)
Sky
  • 1,435
  • 1
  • 15
  • 24
1

No se si esto es lo que buscas.

I dont know if is what you are looking for.

JFrame frame = new JFrame();
final JFXPanel mainJFXPanel = new JFXPanel();
frame.getContentPane().add(mainJFXPanel);
Scene scene = new Scene(rootnode);
mainJFXPanel.setScene(scene);
-1

You can't use swing controls in JavaFX 2.0 because the most super class of a javafx control is Node and in swing most super class is Component. In earlier versions of JavaFx is implemented on top of java swing but version 2.0 is separated form the swing. Therefore JavaFX not providing embedding swing components feature any more.

JanithOCoder
  • 301
  • 2
  • 5
  • 19