将 JFXPANEL 放入窗格

put a JFXPANEL into a Pane

我想将 JFXPanel 用于视频播放器。 我使用 fxml 文件来设计应用程序。 (不适用于视频播放器本身)

...
<VBox>
      <Pane id="VideoEmbedded" fx:id="VideoEmbedded" style="- fx-background-color: #111111;" VBox.vgrow="ALWAYS" />
      <HBox alignment="CENTER" prefWidth="600.0" spacing="8.0" />        
 </VBox>
...

我只想 "replace" 表示用我的 JFXPanel 填充窗格 ("VideoEmbedded")。

//inside the controller
final JFXPanel JFXPanel_VideoEmbedded= new JFXPanel();

@FXML
private JPanel VideoEmbedded;
...
//inside the videoplayer function
VideoEmbedded.add(JFXPanel_VideoEmbedded); //this doesn't work

如何将 JFXPanel 添加到 DOM-层次结构中的正确位置?

 panel.add(jfxPanel, BorderLayout.CENTER);

https://docs.oracle.com/javafx/2/swing/swing-fx-interoperability.htm

或使用 JavaFX Scene Builder(Eclipse、Netbeans 等)

您正在混合使用 Java SwingJavaFX(旧技术和新技术) JPanel VideoEmbedded 是 Java Swing JFXPanel JFXPanel_VideoEmbedded 是 JavaFX

查看此线程 Adding JFXPanel to a JFrame. Why is it not working? 和上面的链接