本文整理汇总了Java中javafx.stage.WindowEvent.consume方法的典型用法代码示例。如果您正苦于以下问题:Java WindowEvent.consume方法的具体用法?Java WindowEvent.consume怎么用?Java WindowEvent.consume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.stage.WindowEvent
的用法示例。
在下文中一共展示了WindowEvent.consume方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleCloseRequest
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
@Override
protected void handleCloseRequest(WindowEvent event) {
if(!gantt.isSaved()) { // TODO add cancel button
ButtonType bt = FXDialog.binaryChoiceAlert("There are unsaved changes in this project. Save and close?").showAndWait().get();
if(bt == ButtonType.YES) {
saveGantt();
} else {
event.consume();
return;
}
}
storageManager.rememberLastViewed(currentFile);
}
示例2: closeWarning
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
private void closeWarning(WindowEvent windowEvent) {
if (areAllPathsValid.get()) {
return;
}
Alert alert = AlertFactory.createAlert(Alert.AlertType.CONFIRMATION, "Unset paths",
"You are trying to close the wizard, but there are unset paths.",
"This might leave the application in a state in which not all features are available. You can run the wizard again later by using the menu entry or specify the paths in the preferences. Are you sure to close the wizard now?");
Optional<ButtonType> returnType = alert.showAndWait();
if (!ButtonType.OK.equals(returnType.get())) {
windowEvent.consume();
}
}
示例3: preventCloseUntilServerShutdown
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
private void preventCloseUntilServerShutdown(WindowEvent event) {
if (serverService.getLocalServerStatus() != SyncingLocalServer.SyncingLocalServerStatus.OFFLINE) {
event.consume();
serverService.cancel();
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setHeaderText("Sync in progress");
alert.setContentText("Please wait until the server has closed and synchronization is complete. If you ignore this warning, " +
"your Minecraft world may be corrupted!");
alert.show();
}
}
示例4: handleClose
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
protected void handleClose(FxWindow w, WindowEvent ev)
{
OnWindowClosing ch = new OnWindowClosing(false);
w.confirmClosing(ch);
if(ch.isCancelled())
{
// don't close the window
ev.consume();
}
}
示例5: handle
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
@Override
public void handle(WindowEvent event) {
/*we want to keep the Arma Dialog Creator window still open when asking to save progress before exiting.
Consuming the event will keep window open and then we call closeApplication to execute the closing procedure and in turn, close the window*/
event.consume();
closeApplication(null);
}
示例6: exit
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
/**
* Exits the program and consumes the event.
*
* @param event The event to consume
*/
protected void exit (final WindowEvent event)
{
this.model.addLogMessage ("Window exit...");
event.consume ();
this.exit ();
}
示例7: handle
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
@Override
public void handle(final WindowEvent event) {
final Alert alert = new Alert(AlertType.CONFIRMATION);
final ButtonType buttonTypeOne = new ButtonType("Yes", ButtonData.OK_DONE);
final ButtonType buttonTypeTwo = new ButtonType("No", ButtonData.NO);
final ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(buttonTypeCancel, buttonTypeTwo, buttonTypeOne);
alert.setTitle("Save changes?");
alert.setHeaderText("Save changes?");
final Optional<ButtonType> result = alert.showAndWait();
if (result.get() == buttonTypeOne) {
try {
final FileChooser fileChooser = new FileChooser();
final File file = SettingsManager.getInstance().getDataFile();
fileChooser.setInitialDirectory(file.getParentFile());
fileChooser.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("Dr.Booking Booking Data", Arrays.asList("*.xml")),
new FileChooser.ExtensionFilter("All Files", "*"));
fileChooser.setTitle("Select File");
fileChooser.setInitialFileName(file.getName());
final File file2 = fileChooser.showSaveDialog(((Stage) event.getSource()));
if (file2 != null) {
SettingsManager.getInstance().setDataFile(file2);
mainController.save(file);
}
} catch (final Exception e) {
logger.error(e.getLocalizedMessage(), e);
}
exit();
} else if (result.get() == buttonTypeTwo) {
exit();
} else {
// cancel shutdown
event.consume();
}
}
示例8: handleClose
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
protected void handleClose(FxDockWindow w, WindowEvent ev)
{
if(getWindowCount() == 1)
{
saveLayout();
}
OnWindowClosing ch = new OnWindowClosing(false);
w.confirmClosing(ch);
if(ch.isCancelled())
{
// don't close the window
ev.consume();
}
}
示例9: onCloseRequest
import javafx.stage.WindowEvent; //导入方法依赖的package包/类
public void onCloseRequest(WindowEvent windowEvent) {
if (!confirmExit()) {
windowEvent.consume();
}
}