public static Rectangle getScreenBounds(final Environment env, final Scene scene) {
GetAction<Rectangle> bounds = new GetAction<Rectangle>() {
@Override
public void run(Object... parameters) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Rectangle sceneBounds = getSceneBounds(env, scene);
Point stageCoordinates = null;
// TODO: stub
String prop = System.getProperty("javafx.swinginteroperability");
if (prop != null && prop.compareToIgnoreCase("true") == 0) {
JFXPanel panel = AWT.getAWT().lookup(JFXPanel.class, new Showing<JFXPanel>() {
@Override
public boolean check(JFXPanel control) {
return super.check(control) && (control.getScene() == scene);
}
}).wrap().getControl();
sceneBounds.translate((int) panel.getLocationOnScreen().getX(), (int) panel.getLocationOnScreen().getY());
} else {
Window window = scene.getWindow();
/*
* Field host_field =
* window.getClass().getDeclaredField("host");
* host_field.setAccessible(true); Object host =
* host_field.get(window); Field panel_field =
* host.getClass().getDeclaredField("this$0");
* panel_field.setAccessible(true); JFXPanel panel =
* (JFXPanel)panel_field.get(host);
* sceneBounds.translate((int)panel.getLocationOnScreen().getX(), (int)panel.getLocationOnScreen().getY());
*/
// TODO: RT-12793
sceneBounds.translate((int) window.getX(), (int) window.getY());
}
setResult(sceneBounds);
}
};
env.getExecutor().execute(env, true, bounds);