Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Coordinates of an html object in webview javafx

4317371Aug 30 2020 — edited Sep 1 2020

Coordinates of an html object in webview

Is it possible to find out the position of an object on the screen via html or javascript in webview javafx?
Ex: I want to get the X and Y from the position of a button. Know exactly where it is on the screen so I can place the mouse exactly on top of it.

I know the mouse moves, I just need to get the coordinates of some object.

If you know another way you can feel free to share.

I can already get it in javascript, now I want to retrieve the variables to use in java

function myFunction() {

  var div = document.getElementById('btEnvia');

  var rect = div.getBoundingClientRect();

  x = rect.left;

  y = rect.top;

  w = rect.width;

  h = rect.height;

  alert ("Left: " + x + ", Top: " + y + ", Width: " + w + ", Height: " + h);

}

=======================

É possível descobrir a posição de um objeto na tela via html ou javascript  em webview javafx?

Ex: quero pegar o X e Y da posição de um button.  Saber exatamente em qual local ele está na tela para que eu possa colocar o mouse exatamente em cima dele.

Mover o mouse já sei, só falta pegar as coordenadas de algum objeto.

Caso conheça outra forma pode ficar a vontade para compartilhar.

Já consigo pegar em javascript, agora quero recuperar as variáveis para utilizar no java

Comments

Post Details

Added on Aug 30 2020
0 comments
384 views