本文整理匯總了Java中javafx.scene.control.Alert.setOnCloseRequest方法的典型用法代碼示例。如果您正苦於以下問題:Java Alert.setOnCloseRequest方法的具體用法?Java Alert.setOnCloseRequest怎麽用?Java Alert.setOnCloseRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Alert
的用法示例。
在下文中一共展示了Alert.setOnCloseRequest方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nextLevel
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public void nextLevel(){
if(!(currentLevel == numLevels)){
Alert winAlert = new CustomAlert(AlertType.CONFIRMATION, "You beat the level!");
winAlert.setOnCloseRequest(e -> bus.emit(new GamePauseResumeEvent()));
winAlert.show();
bus.emit(new GamePauseResumeEvent());
///System.out.println("next level loading");
currentLevel++;
//System.out.println("Current level: " + currentLevel);
loadLevel(data.get(currentLevel-1));
return;
}
new WinPresentation().show(new ResultAccessor());;
bus.emit(new WinGameEvent(WinGameEvent.WIN));
bus.emit(new GamePauseResumeEvent());
}
示例2: end
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* Method to be called on song end
* @param lastReport last GameReport
*/
private void end(GameReport lastReport) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Clone Hero");
alert.setHeaderText("You've completed this song!");
alert.setContentText("Your score: " + lastReport.getScore());
alert.setOnCloseRequest(new EventHandler<DialogEvent>() {
@Override
public void handle(DialogEvent event) {
stage.hide();
}
});
alert.show();
}