我有一个无法正常工作的事件监听器,我找不到原因:
public void initCloseConfigurationPanelDialog(final Stage primaryStage)
{
final Stage dialog = new Stage();
// If you want to freeze the background during dialog appearence set
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.initOwner(primaryStage);
// Button "Yes"
Button btnYes = new Button("Yes");
btnYes.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent event)
{
primaryStage.close();
}
});
btnYes.setDefaultButton(true);
// Button "No"
Button btnNo = new Button("No");
btnNo.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent event)
{
primaryStage.show();
dialog.close();
}
});
btnNo.setCancelButton(true);
.....................................................
// Stage
Scene scene = new Scene(bp, 500, 140);
dialog.setScene(scene);
dialog.show();
}
按ENTER键时,按下Yes
按钮。但是当我按ESCAPE时没有变化。知道为什么吗?