On Sat, 28 Oct 2023 07:15:12 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
>> modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 822: >> >>> 820: scene.setNodeOrientation(rtl ? >>> 821: >>> NodeOrientation.RIGHT_TO_LEFT : >>> 822: >>> NodeOrientation.LEFT_TO_RIGHT); >> >> I don't think this is the right place to fix it. The default value for >> `nodeOrientation` is `INHERIT`, and in case it is not overridden, we want >> the effective orientation to be returned as RTL or LTR. In the case where it >> is overridden, it would be wrong to modify it. >> >> Even when it is INHERIT, we don't want to modify the actual property value, >> but rather want to compute the effective orientation to take the Swing >> component's orientation into account. See >> [Scene::calcEffectiveNodeOrientation](https://github.com/openjdk/jfx/blob/9b93c962f45e5cf0b3a9f1090f307603be130a0e/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java#L6343). >> I think you should be able to add logic to check whether the scene's window >> is an embedded stage, and then to call a method in embedded stage that would >> delegate to JFXPanel to get the component's node orientation. That way it >> would only alter the effective node orientation (and not the property), and >> would only do it when the property was `INHERIT`. > > I have tried to put in place what you suggested. Can you please take a look > at the PR and see if it's in the right direction and suggest further. > I have few doubts > > - It seems JFXPanel call EmbeddedStage interface methods and not the other > way round, so I am not sure how to "call a method in embedded stage that > would delegate to JFXPanel". > - It seems > [Scene::calcEffectiveNodeOrientation](https://github.com/openjdk/jfx/blob/9b93c962f45e5cf0b3a9f1090f307603be130a0e/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java#L6343) > is private and not part of swing-interop code/package so I am not sure how > to leverage it from JFXPanel/EmbeddedStage....I have tried setting > EmbeddedStage orientation from JFXPanel and query it from Scene but am not > sure how to call `calcEffectiveNodeOrientation` Yes, you are right that JFXPanel needs to call into the stage and not the other way around. The general approach now looks correct, however, you'll need to add the orientation attribute on the JavaFX Window (`EmbeddedWindow`) not on the peer (`EmbeddedStage`). The other thing you will need is to to call `SceneHelper::parentEffectiveOrientationInvalidated` from `EmbeddedWindow::setOrientation` when the value of the orientation changes. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1271#discussion_r1375303738