Mixing JavaFX with Swing in different windows

Anthony Petrov anthony.petrov at oracle.com
Tue Apr 24 08:29:33 PDT 2012


On 4/24/2012 7:21 PM, Artem Ananiev wrote:
> 
> On 4/24/2012 6:04 PM, Josh Marinacci wrote:
>> Has anyone had luck building an app with one window that is Swing and
>> the other is JavaFX?  I want to slowly moving my large app
>> (LeonardoSketch.org)  over to JavaFX.
> 
> It should just work, otherwise it's a bug. Create a JFXPanel object (it 
> will trigger JFX runtime initialization), then use Platform.runLater() 
> to create FX toplevels.

I think we might want to file an RFE to improve this so that a user 
wouldn't have to create a JFXPanel first. It should be possible to 
detect whether AWT has been initialized already, and thus choose to 
initialize FX in the embedded mode behind the scenes (upon first 
Platform.invokeLater() call, for example, or we may even want to 
introduce a separate API for this kind of initialization).

--
best regards,
Anthony

> 
>> I have built a new window in JavaFX but I get some init errors on
>> startup. Instead I can put the FX content inside of a JXPanel, but
> 
> Could you provide more information about these errors, please?
> 
>> many things break on the FX side like drag and drop. I would rather
> 
> DnD in JFXPanel is fixed in 2.2, at least on Windows platform.
> 
>> run the FX content in a real FX stage.  I am fine having one window
>> be run on the FX thread and one on the Swing thread with me being
>> responsible for synchronization via invokeLater calls.  I'm wondering
>> if there is any magic init-mojo required.
>>
>> Thanks
>> Josh
> 
> Thanks,
> 
> Artem


More information about the openjfx-dev mailing list