javafx,如何实现confirmHandler?
我正在使用javafx的webengine来显示网页。在页面上,有脚本调用window.confirm。我已经知道如何设置确认处理程序以及如何显示类似模态的对话框 我的问题是如何在处理程序返回之前获得用户的选择javafx,如何实现confirmHandler?,javafx,javafx-2,Javafx,Javafx 2,我正在使用javafx的webengine来显示网页。在页面上,有脚本调用window.confirm。我已经知道如何设置确认处理程序以及如何显示类似模态的对话框 我的问题是如何在处理程序返回之前获得用户的选择 webEngine.setConfirmHandler(new Callback<String, Boolean>() { @Override public Boolean call(String message) { // Show the dialog ... retur
webEngine.setConfirmHandler(new Callback<String, Boolean>() {
@Override
public Boolean call(String message) {
// Show the dialog
...
return true; // How can I get user's choice here?
}
});
如中所述,我们可以使用JavaFX2.2中提供的新方法showAndWait来实现这一点
舞台类:
/**
* Show the stage and wait for it to be closed before returning to the
* caller. This must be called on the FX Application thread. The stage
* must not already be visible prior to calling this method. This must not
* be called on the primary stage.
*
* @throws IllegalStateException if this method is called on a thread
* other than the JavaFX Application Thread.
* @throws IllegalStateException if this method is called on the
* primary stage.
* @throws IllegalStateException if this stage is already showing.
*/
public void showAndWait();
@jewelsea在上创建了一个样本。谢谢 嗯。阻塞将在2.2中提供。必须等待…为什么不把你的答案放在评论中,并将其标记为已接受的答案?@jschoen,因为2.2尚未发布。但我会在回答中写下我的发现。