dimanche 28 août 2016

JavaFX WebView - get document(content) height

I am actually developing a java chat application, to display the messages i use a Panel which has a Label, a Separator and a WebView as children. To properly size the WebView and make it fit its content i am using JavaScript

private void sizeWebViewProperly()
{
    String heightText = messageContainer.getEngine().executeScript("document.height").toString();
    messageContainer.setPrefHeight(Double.valueOf(heightText.replace("px", "")));
}

However , for every letter that is inside of the webview it adds a lineheight to the website height.

enter image description here

That is the css i am using:

body
{
    word-wrap: break-word;
}

Does anyone know why this happens? Instead of document.height i have already tried document.clientHeight, document.offsetHeight and document.scrollHeight.




Aucun commentaire:

Enregistrer un commentaire