JFXPanel
Scott Palmer
swpalmer at gmail.com
Wed Jan 2 11:06:51 PST 2013
On 2013-01-02, at 1:25 PM, Werner Lehmann <lehmann at media-interactive.de> wrote:
> Hi Anthony,
>
> On 24.12.2012 11:18, Anthony Petrov wrote:
>> The only way to implement this reliably is to use the handle to the
>> native Swing window as an owner for the FX dialog, which is not
>> currently possible unfortunately.
>
> that would be a wet dream. Being able to use a dialog owner Stage *or JFrame or JDialog or awt.Window* for modality and z-order.
>
>> I understand the need for this completely. However, I doubt this
>> possibility would be useful for FX in the long run, especially given
>> that workarounds exist. For example, you could use a Swing modal dialog
>> to achieve the same result - just put your modal FX content into another
>> JFXPanel and embed it into the JDialog. Or, as you're suggesting above,
>
> This is the only real option here, in my opinion. But the code for this is more convoluted than it should be (e.g. EDT/FX sync code etc). And for a migration path Swing to FX this means to touch all those dialogs twice:
>
> 1. replace JDialog content with JFXPanel, and later
> 2. replace JDialog with Stage
>
> The second step can only be started when the whole parent chain is in FX land. This means there will be one point in time where we need to switch the main window from JFrame to Stage and immediately change every other window in the app from JDialog to Stage (because JDialog does not accept a Stage owner). That does not sound like a good option to me, for non-trivial applications.
I intend to pursue this by creating some helper methods to show a dialog containing a single Parent node. Depending on the parent object for the dialog it would automatically wrap the node in a JFXPanel and use a JDialog, or use a Stage. That way I keep the ugly stuff in one place and don't have to revisit all those dialogs.
** Ideally this would be something from JFXtras **
>> you could disable the panel manually which wouldn't fix the z-order but
>> at least would provide some kind of modality. A third approach is to get
>
> Nightmarish, and proper z-order is not optional...
>
>> rid of the JFXPanel altogether and put your FX content into a real FX
>> top-level window.
>
> With the current "FX embedded in Swing" method this can only be the ultimate step, when everything else is already converted to FX. This is a few years away in our case. Things would be better if there was an option to use the "Swing embedded in FX" model because then we could slowly push out Swing top down. But that's not how it works now.
It's nice to know that I am not alone.
Scott
More information about the openjfx-dev
mailing list