Skip to content

Instantly share code, notes, and snippets.

@Splaktar
Last active January 1, 2016 20:39
Show Gist options
  • Save Splaktar/8198695 to your computer and use it in GitHub Desktop.
Save Splaktar/8198695 to your computer and use it in GitHub Desktop.
Alert and Confirm handlers for a JavaFX WebView hosted in a Swing application.
engine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> event) {
JOptionPane.showMessageDialog(
myPanel,
event.getData(),
"Alert Message",
OptionPane.ERROR_MESSAGE);
}
});
engine.setConfirmHandler(new Callback<String, Boolean>() {
@Override public Boolean call(String msg) {
int result = JOptionPane.showConfirmDialog(
myPanel,
msg,
PLANT + "Confirm Message",
JOptionPane.OK_CANCEL_OPTION);
return result == 0 ? true : false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment