JFXPanel as the content of a DefaultSingleCDockable

Hello everyone!
I have an idea of an application in mind and I thought of using JavaFX to implement it, but as turned out there were no decent docking frameworks for JavaFX (at least none that I could find). So I came across DockingFrames and it looked really great. I created a small test app with 3 docking panels and it worked great.

Then I tried to add a JFXPanel (it’s a component to embed javafx content into swing applications according to the API docs JFXPanel (JavaFX 2.2) here’s how it works: 3 Integrating JavaFX into Swing Applications (Release 8)) as the content of a DefaultSingleCDockable; and then I encountered a problem.
The content is displayed correctly, the test button I added to the JFXPanel works correctly, but when I minimize the panel or undock/dock it, the content of the panel just disappears.

The tutorial I used (the link above) says that “JavaFX data should be accessed only on the JavaFX User thread. Whenever you must change JavaFX data, wrap your code into a Runnable object and call the Platform.runLater method…” but I don’t access any data, so I’m out of ideas. The only solution I see now is to abandon JavaFX and use pure Swing to implement my app.

So does anyone have any ideas why the javafx content disappears when the dockable gets undocked/docked?

Both times the content of the Dockable is shown on a new window, maybe JavaFX does not like if its parent window changes.

I am having a similar problem. My app loads a layout that puts two JFxPanels in dockables that are tabbed on one side of the app. I can move a dockable to another part of the app, but as soon as I drop one dockable on top of another (such that they displayed as tabbed), both panels disappear and never come back. It does appear to be a JavaFX problem. It occurs for both JavaFX 2.2 and 8.

I tried using a location change listener to reset visibility on the scene, but this did not help.

I am stumped. Any advice would be greatly appreciated.

I have found a solution. Apparently addNotify needs to be called due to the parent change. This can be done using CDockableChangeListener as follows (code is in Scala):

  def addDialog(id: DialogId, scene: Scene): Unit = {
    val (dockable, panel) = createDockable(id.id, scene)//function returns a tuple where "panel" is the JFxPanel

    dockable.addCDockableLocationListener(new CDockableLocationListener {
      override def changed(event: CDockableLocationEvent): Unit = {
        panel.addNotify()//capture in lambda
      }
    })

    mControl.addDockable(dockable)
    mDockables = dockable :: mDockables
    dockable.setVisible(true)
  }