JavaFx WebEngine get content from an Iframe

2

I can not tell when an Iframe changes

I use listener to always know that the page is loaded in WebEngine, however this listener can not know when the Iframe is changed / loaded.

Is there any way to detect differences / changes within Iframe

Code: HTML

<iframe id="principal" name="principal"</iframe>

JavaFx

engine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
    @Override
    public void changed(ObservableValue ov, State oldState, State newState) {
        if (newState == State.SUCCEEDED) {
            System.out.println("Location" + engine.getLocation());

            Document doc = engine.getDocument();
            HTMLIFrameElement iframeElement = (HTMLIFrameElement) doc.getElementById("principal");
            Document iframeContentDoc = iframeElement.getContentDocument();
            //Element rootElement = iframeContentDoc.getDocumentElement();
            //System.out.println(rootElement.getTextContent());

            NodeList nodeList = iframeContentDoc.getElementsByTagName("a");
            System.out.println("Total de tabs " + nodeList.getLength());  // <--- Dá 0 porque o Iframe ainda não estava carregado, se esperar um pouco consigo obter a informação, contudo nunca sei quando este Iframe está completamente carregado ou foi alterado

        }

    }

});

Can I put a listener in this component? How do I know when to upload or change content?

    
asked by anonymous 22.02.2018 / 13:05

0 answers