Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I embed a JFrame into a JavaFX 2.0 application?

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.

like image 978
adeena Avatar asked Nov 02 '22 05:11

adeena


2 Answers

  1. Create a SwingNode s
  2. Create a JComponent c
  3. Call s.setContent(c)
like image 113
SUMA GOPALAKRISHNA Avatar answered Nov 15 '22 04:11

SUMA GOPALAKRISHNA


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);
like image 28
Flavio Nicolas Rossi Avatar answered Nov 15 '22 05:11

Flavio Nicolas Rossi