anthony.petrov at oracle.com
Mon Dec 24 02:18:23 PST 2012
On 12/21/2012 18:54, Scott Palmer wrote:
> The underlying JFXPanels are an implementation detail of how the Window is rendered… having per-panel modality built-in seems very strange. It's like asking should I block other JButtons on my Swing panel after hitting the JButton that brings up my JOptionPane. It doesn't make sense, the JOptionPane blocks the entire parent Window, no just some small part of it.
JOptionPane is not the best example here since the API accepts a
component as a modal owner. It's a Swing-specific feature. Let's talk
JDialog here? It's more close to normal modal dialogs known in other GUI
toolkits, including FX. A dialog requires a top-level window as its
owner. Now, if we consider a JFXPanel, it is not a top-level window by
any means. It is a component embedded across different GUI toolkits.
> The Modality of the dialog is what matters, and as I understand it, that relates only to the parent Window and other top-level Windows in the application - embedded "windows" don't count because they aren't something the user is even supposed to be aware of.
> Anyway.. the blocking can be dealt with in the application code if need be (make the Dialog modeless and block the panel via other means). It isn't even the issue. It is the Window hierarchy that is the issue. Dialogs should never go behind their parent window. That's the only bug I would be trying to address for now.
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.
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,
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
rid of the JFXPanel altogether and put your FX content into a real FX
> On 2012-12-21, at 8:09 AM, Anthony Petrov <anthony.petrov at oracle.com> wrote:
>> It isn't obvious to me, however. Suppose I add several JFXPanels into a single Swing top-level window. I may want to show a modal dialog for the first JFXPanel, but leave others operable, for example. This use case seems to be quite valid.
>> best regards,
>> On 12/21/2012 16:09, Scott Palmer wrote:
>>> The whole Swing window must be blocked, if possible. I don't even understand why this is a question. If I show a JOptionPane and I give a JPanel as the "parent" component, does it block only the JPanel? This is no different. Can you give me an example of when you would only want the JFXPanel blocked?
>>> On 2012-12-21, at 4:52 AM, Anthony Petrov <anthony.petrov at oracle.com> wrote:
>>>> Hi Scott,
>>>> I think that technically this could be implemented.
>>>> However, there's a problem: when you create a modal FX dialog specifying a JFXPanel instance as its owner - should the whole Swing window be blocked while the dialog is showing, or should the JFXPanel be disabled only? Why?
>>>> From logical perspective there's not a perfect answer to the above question. No matter what decision we make, some people could get upset.
>>>> best regards,
>>>> On 12/21/2012 7:00, Scott Palmer wrote:
>>>>> On 2012-12-17, at 5:55 AM, Artem Ananiev <artem.ananiev at oracle.com> wrote:
>>>>>> On 12/14/2012 8:19 PM, Werner Lehmann wrote:
>>>>>>> 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
>>>>>> Yes, z-order and modality problems with Swing and FX top-level windows is a known issue. Unfortunately, I don't know a good way to fix it: AWT/Swing doesn't expose enough information to use its windows as owner windows for other UI toolkits.
>>>>> I responded earlier wondering why the native window handle of the Swing Window wasn't acquired via the publicly available jawt native methods so it could be used as the parent for a Stage or worked into some sort of hierarchy to give a proper parent window to FX Stages and dialogs. I didn't see any response. Am I missing something?
>>>>> I already do this (get and use the native window handle) in a Swing app so that I can blit live video into my Swing app., a high-end video capture/transcoder/broadcast application. (See http://www.digitalrapids.com/en/Products/StreamZHD.aspx or the one that really could have used FX if it was ready earlier http://www.digitalrapids.com/en/Products/TouchStream.aspx)
>>>>> I actually have a need to do the same with a JavaFX app .. but there is no equivalent in FX land for the jawt JNI methods. (I asked for this years ago in the Java FX 1.0 days.)
>>>>> Is all of the code involved in JFXPanel->Scene->Window Open Source? I went poking around but didn't find the implementation of com.sun.javafx.tk.quantum.QuantumToolkit which I think is used to create the peer of the EmbeddedWindow used as the Window for JFXPanels.
More information about the openjfx-dev