JFXPanel
Anthony Petrov
anthony.petrov at oracle.com
Fri Dec 21 01:41:03 PST 2012
You should never perform anything of "AndWait" kind on a GUI event
thread. This applies to any GUI toolkit, be it Java-based (e.g. Swing or
FX), or a native API (e.g. WinAPI or Cocoa). Never.
The only case when you may "block" an event thread is when you show a
modal dialog using an API of the GUI toolkit on the event thread of
which you're currently running, or when you're starting a DragAndDrop
operation from an event handler. In both these cases the toolkit will
run a nested event loop for you so that GUI events are properly
processed during the blocking operation, and therefore your application
won't appear "frozen" to the end user.
I realize that you want to display a JOptionPane modally from FX
perspective, but unfortunately this isn't quite possible. You should
either use an FX modal dialog for this purpose, or display the modal
JOptionPane from Swing code.
--
best regards,
Anthony
On 12/21/2012 6:23, Jeff Martin wrote:
> Is it possible to run a JOptionPane from the FXApplicationThread with SwingUtilities.invokeAndWait()?
>
> I tried it and it hangs in CCursorManager.nativeGetCursorPosition() (which I've seen before when I've accidentally run swing code from the FXApplication thread).
>
> jeff
>
> On Dec 14, 2012, at 10:19 AM, Werner Lehmann <lehmann at media-interactive.de> wrote:
>
>> Scott,
>>
>> JFXPanel has quite a few issues (look for JFXPanel or Swing in Jira). Among those is the filechooser problem. It is probably just one instance of the problem that a JavaFX stage cannot be modal or on top of Swing windows.
>>
>> To work around this we have to put JFXPanels in JDialogs. Not really sexy: apart from the overhead in code we know today that we have to touch this again one day to convert the JDialog to a stage.
>>
>> Regarding your problem of how to get from a node to the JFXPanel: no idea why you would want to do this. I have a dozen jfxpanels but never needed such a thing. I guess you could extend JFXPanel and add a reference to the fxpanel to some userdata on a node, or something like that.
>>
>> Rgds
>> Werner
>>
>> On 14.12.2012 16:39, Scott Palmer wrote:
>>> I'm trying to migrate more of my app from Swing to JavaFX piece-wise
>>> via JFXPanels. It's not fun as there are many rough edges. In order
>>> to work around some of them I am wondering if it is possible to get a
>>> reference to the JFXPanel if all I have is a Node? I can get the
>>> Scene's Window, an "Embedded" Window that seems to be the root of a
>>> lot of problems with popups and dialogs. That seems to be enough to
>>> determine that the Node is hosted by a JFXPanel, but can I actually
>>> get the JFXPanel instance?
>>>
>>> If there is a way via public APIs that don't rely on me peaking at
>>> implementation details like com.sun.javafx.stage.EmbeddedWindow?
>>>
>>> Along this line… why is it that things like the FileChooser and other
>>> JavaFX dialogs don't respect the window ordering when used from a
>>> JFXPanel? They easily flip behind the parent JFrame. I would have
>>> thought that the correct Window hierarchy in native land could still
>>> include the native window of the JFrame and that should prevent such
>>> things.
>>>
>>> Scott
>
More information about the openjfx-dev
mailing list