本文整理匯總了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();
}
}