* @return the web view
*/
protected WebView createWebView(final String fileName,
final String navResultImgSrc, final String navImgSrc,
final boolean isCam) {
final WebView webView = new WebView();
webView.getEngine().getLoadWorker().stateProperty()
.addListener(new ChangeListener<State>() {
@Override
public void changed(
ObservableValue<? extends State> observable,
State oldValue, State newValue) {
if (newValue == State.SUCCEEDED
&& webView.getEngine().getDocument() != null) {
getCurrentPageSource();
// webView.getEngine().executeScript("complete()");
// try {
// final DocumentFragment frag = webView.getEngine().getDocument().createDocumentFragment();
// frag.setNodeValue(getContent(true));
// final HTMLElement html = (HTMLElement) webView.getEngine().getDocument().getElementsByTagName("body").item(0);
// html.appendChild(frag);
// } catch (Throwable t) {
// t.printStackTrace();
// }
// /*
// * link =item.getAttributes().getNamedItem("src").
// * getTextContent();
// */
// body.getAttributes().getNamedItem("src")
// .setNodeValue(navImgSrc);
// final Element navResultImg = webView.getEngine()
// .getDocument()
// .getElementById("navResultImg");
// navResultImg.getAttributes().getNamedItem("src")
// .setNodeValue(navResultImgSrc);
}
}
});
webView.getEngine().getLoadWorker().exceptionProperty()
.addListener(new ChangeListener<Throwable>() {
@Override
public void changed(
final ObservableValue<? extends Throwable> observableValue,
final Throwable oldThrowable, final Throwable newThrowable) {
System.out.println("Load exception: " + newThrowable);
}
});
webView.getEngine().setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
@Override
public WebEngine call(PopupFeatures popupFeatures) {
// TODO Auto-generated method stub
return null;
}
});
webView.getEngine().setPromptHandler(new Callback<PromptData, String>() {
@Override
public String call(final PromptData promptData) {
//promptData.
return null;
}
});
webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> event) {
return;
// if (event.getData().indexOf(NAVIGATE_JS) > -1) {
//