Hi,

I could not resist giving my idea a try and passing the native-pointer
from SWT completely through JavaFX and using it as a parent on Windows
created by FX.

Although my C/Objective-C knowledge is next to useless it works and now
Popup-Windows (eg created by a DropDown are a Native-Child of their
SWT-NSWindow which means they move if you move the window, they don't
hide behind their parent, ...) - they just work as they do in a native
JavaFX application!

I'll create an issue and we can move the discussion there.

Tom

On 31.07.18 15:16, Tom Schindl wrote:
> hi,
> 
> yes and I can confirm that the date-picker issue is not that dramatic on
> Windows. If I modify my test case just a bit by opening my own stage
> with a parent-stage the z-order at least can also get messed up on windows.
> 
> package test;
> 
> import javax.swing.JFrame;
> 
> import javafx.application.Platform;
> import javafx.embed.swing.JFXPanel;
> import javafx.geometry.Pos;
> import javafx.scene.Scene;
> import javafx.scene.control.Button;
> import javafx.scene.control.ColorPicker;
> import javafx.scene.layout.BorderPane;
> import javafx.stage.Stage;
> 
> public class TestSwingInterop extends JFrame {
> 
>     public TestSwingInterop() {
>         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>         final JFXPanel fxPanel = new JFXPanel();
>         add(fxPanel);
> 
>         Platform.runLater(new Runnable() {
>             @Override
>             public void run() {
>                 initFX(fxPanel);
>             }
>         });
>     }
> 
>     static void initFX(JFXPanel fxPanel) {
>         // This method is invoked on JavaFX thread
>         Scene scene = createScene();
>         fxPanel.setScene(scene);
>     }
> 
>     static Scene createScene() {
>         ColorPicker picker = new ColorPicker();
>         BorderPane.setAlignment(picker, Pos.TOP_LEFT);
>         BorderPane p = new BorderPane(picker);
>         Button button = new Button("Extra Stage");
>         button.setOnAction( evt -> {
>             Stage s = new Stage();
>             s.setScene(new Scene(new BorderPane(new Button("Hello
> World")), 300, 300));
>             s.initOwner(button.getScene().getWindow());
>             s.show();
>         });
>         p.setBottom(button);
> 
>         return new Scene(p);
>     }
> 
>     public static void main(String[] args) {
>         TestSwingInterop s = new TestSwingInterop();
>         s.setBounds(100, 100, 1000, 800);
>         s.setVisible(true);
>     }
> }
> 
> package test;
> 
> import javafx.application.Application;
> import javafx.stage.Stage;
> 
> public class TestPlainFX extends Application {
> 
>     @Override
>     public void start(Stage primaryStage) throws Exception {
>         primaryStage.setScene(TestSwingInterop.createScene());
>         primaryStage.show();
>     }
> 
>     public static void main(String[] args) {
>         launch(args);
>     }
> }
> 
> If you run an click the "Extra - Stage" Button you'll notice that the
> main Swing window can get infront of it child (this is a similar problem
> than the Picker). The same does not work if you are in pure FX.
> 
> Tom
> Am 2018-07-31 14:57, schrieb Kevin Rushforth:
>> OK, I can reproduce it on Mac using JDK 11-ea and the latest jfx-dev.
>> Can you file a bug?
>>
>> -- Kevin
>>
>>
>> On 7/31/2018 5:51 AM, Tom Schindl wrote:
>>> Hi,
>>>
>>> I'm on Mac as well and just gave 8u181 a spin and see the same problem
>>> (beside others eg the DropDown popup does not move with window).
>>>
>>> Just to make sure: It is curcial to not only bring up the DropDown-List
>>> but also open the Dialog-Window with the color-spectrum, ... .
>>>
>>> Tom
>>>
>>> On 31.07.18 14:34, Michael Paus wrote:
>>>> I did the test on a Mac.
>>>>
>>>> MacOS High Sierra
>>>> OpenJDK12ea4
>>>> OpenJFX11ea20 (SDK)
>>>>
>>>> I just ran the code and repeated the steps given by Tom.
>>>> * Bring up the DropDown-List
>>>> * Bring up the custom color dialog
>>>> * Click somewhere in the JFrame
>>>>
>>>> Michael
>>>>
>>>> Am 31.07.18 um 14:19 schrieb Kevin Rushforth:
>>>>> I ran the test program on Windows 7 using JDK-11+24 plus my local
>>>>> build of openjfx 11, and I can't reproduce the problem. I suspect that
>>>>> Prasanta is correct in that this was fixed for FX/Swing interop by
>>>>> JDK-8185634 (on the FX side) and JDK-8187803 (on the AWT side). I
>>>>> don't know why you and Tom are still seeing this bug. What platform
>>>>> are you testing on?
>>>>>
>>>>> Note that this won't help SWT interop, though. A similar fix might be
>>>>> needed there (once we understand why the Swing interop test program
>>>>> isn't working for some of you).
>>>>>
>>>>> -- Kevin
>>>>>
>>>>> On 7/31/2018 4:45 AM, Michael Paus wrote:
>>>>>> Hi Tom
>>>>>> I gave it a try with the latest OpenJDK12ea and OpenJFX11ea and I
>>>>>> still
>>>>>> see the same baviour which you described.
>>>>>> Michael
>>>>>>
>>>>>> Am 31.07.18 um 13:08 schrieb Tom Schindl:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I give it a try but from the bug description and discussion I would
>>>>>>> have
>>>>>>> assumed it deals with the opposite problems (Opening a Swing-Dialog
>>>>>>> from
>>>>>>> an JavaFX-Application who uses Swing-Node).
>>>>>>>
>>>>>>> I also studied the code to see if how you make a JavaFX-Stage
>>>>>>> having a
>>>>>>> different owner but I could only find changes to AWT deal with this.
>>>>>>>
>>>>>>> Anyways I'll try to get it the latest master running. The issue
>>>>>>> states
>>>>>>> that it is fixed in 8u182 but only 8u181 is available and there
>>>>>>> are no
>>>>>>> EA-Builds of Java8 available anymore (Looks like Oracle does not
>>>>>>> want
>>>>>>> people to test fixes for upcoming 8-update anymore)
>>>>>>>
>>>>>>> Tom
>>>>>>>
>>>>>>> On 31.07.18 11:21, Prasanta Sadhukhan wrote:
>>>>>>>> Hi Tom,
>>>>>>>>
>>>>>>>> I am not able to see the problem in latest workspace. I believe
>>>>>>>> this
>>>>>>>> issue is already fixed by JDK-8185634.
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Prasanta
>>>>>>>> On 7/31/2018 1:16 PM, Tom Schindl wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> In one of our customers application we have major problems when
>>>>>>>>> embedding JavaFX into SWT (but from my tests the situation is
>>>>>>>>> equal for
>>>>>>>>> Swing).
>>>>>>>>>
>>>>>>>>> In the end all windows (most commonly popup-windows) are affected
>>>>>>>>> because they don't have a parent-window assigned and so they
>>>>>>>>> can be
>>>>>>>>> hidden by the window embedding them - if the window opened is
>>>>>>>>> Modal like
>>>>>>>>> eg the one from ColorPicker the JavaFX UI is also blocked.
>>>>>>>>>
>>>>>>>>> To see what I mean just use this snippet below and do the
>>>>>>>>> following:
>>>>>>>>> * Bring up the DropDown-List
>>>>>>>>> * Bring up the custom color dialog
>>>>>>>>> * Click somewhere in the JFrame
>>>>>>>>>
>>>>>>>>> You notice the following:
>>>>>>>>> * JavaFX Window is moved behind Swing-Window
>>>>>>>>> * JavaFX UI is blocked
>>>>>>>>>
>>>>>>>>>> package test;
>>>>>>>>>>
>>>>>>>>>> import javax.swing.JFrame;
>>>>>>>>>>
>>>>>>>>>> import javafx.application.Platform;
>>>>>>>>>> import javafx.embed.swing.JFXPanel;
>>>>>>>>>> import javafx.geometry.Pos;
>>>>>>>>>> import javafx.scene.Scene;
>>>>>>>>>> import javafx.scene.control.ColorPicker;
>>>>>>>>>> import javafx.scene.layout.BorderPane;
>>>>>>>>>>
>>>>>>>>>> public class TestSwingInterop extends JFrame {
>>>>>>>>>>            public TestSwingInterop() {
>>>>>>>>>>           setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>>>>>>>>>>           final JFXPanel fxPanel = new JFXPanel();
>>>>>>>>>>            add(fxPanel);
>>>>>>>>>>                     Platform.runLater(new Runnable() {
>>>>>>>>>>                @Override
>>>>>>>>>>                public void run() {
>>>>>>>>>>                    initFX(fxPanel);
>>>>>>>>>>                }
>>>>>>>>>>            });
>>>>>>>>>>       }
>>>>>>>>>>            private static void initFX(JFXPanel fxPanel) {
>>>>>>>>>>            // This method is invoked on JavaFX thread
>>>>>>>>>>            Scene scene = createScene();
>>>>>>>>>>            fxPanel.setScene(scene);
>>>>>>>>>>        }
>>>>>>>>>>            private static Scene createScene() {
>>>>>>>>>>           ColorPicker picker = new ColorPicker();
>>>>>>>>>>           BorderPane.setAlignment(picker, Pos.TOP_LEFT);
>>>>>>>>>>           BorderPane p = new BorderPane(picker);
>>>>>>>>>>                   return new Scene(p);
>>>>>>>>>>       }
>>>>>>>>>>
>>>>>>>>>>       public static void main(String[] args) {
>>>>>>>>>>           TestSwingInterop s = new TestSwingInterop();
>>>>>>>>>>           s.setBounds(100, 100, 1000, 800);
>>>>>>>>>>           s.setVisible(true);
>>>>>>>>>>       }
>>>>>>>>>> }
>>>>>>>>> I've tested this on Java8 and Java9 but didn't had a chance to run
>>>>>>>>> it on
>>>>>>>>> the latest master.
>>>>>>>>>
>>>>>>>>> The problem is that the newly created JavaFX windows don't have
>>>>>>>>> the
>>>>>>>>> Native-Window as their parent but the EmbeddedStage (who is not
>>>>>>>>> bound to
>>>>>>>>> a native-window handle). It looks like EmbeddedStage has
>>>>>>>>> already been
>>>>>>>>> prepared (see getRawHandle() : long) to support something like
>>>>>>>>> that in
>>>>>>>>> future but com.sun.glass.ui.Window and its subclasses have
>>>>>>>>> never been
>>>>>>>>> extend to create a window based on a pure long-pointer.
>>>>>>>>>
>>>>>>>>> The only exception and the reason I guess the strategy would
>>>>>>>>> work was
>>>>>>>>> used for Applets.
>>>>>>>>>
>>>>>>>>> Before diving deeper into this I wanted to get a feedback from
>>>>>>>>> people
>>>>>>>>> who know things better: Does the strategy of passing along the
>>>>>>>>> window
>>>>>>>>> pointer (eg from SWT, don't know about Swing yet) to Glass and
>>>>>>>>> using it
>>>>>>>>> as the parent pointer sound like a proper idea?
>>>>>>>>>
>>>>>>>>> Tom
>>>>>>>>>

-- 
Tom Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7. A-6020 Innsbruck
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck

Reply via email to