本文整理匯總了Java中javafx.scene.control.Alert.initModality方法的典型用法代碼示例。如果您正苦於以下問題:Java Alert.initModality方法的具體用法?Java Alert.initModality怎麽用?Java Alert.initModality使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Alert
的用法示例。
在下文中一共展示了Alert.initModality方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showDialog
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public void showDialog() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/diff/diff-view.fxml"));
try {
loader.setController(diffController);
DialogPane root = loader.load();
root.getStylesheets().add(getClass().getResource("/gui/diff/diff-view.css").toExternalForm());
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Diff Viewer");
alert.setResizable(true);
alert.setDialogPane(root);
alert.initModality(Modality.WINDOW_MODAL);
Window window = alert.getDialogPane().getScene().getWindow();
window.setOnCloseRequest(event -> window.hide());
alert.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: showDialog
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public boolean showDialog() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/conflict/resolve-conflicts-view.fxml"));
try {
loader.setController(conflictManagerController);
DialogPane root = loader.load();
root.getStylesheets().add(getClass().getResource("/gui/conflict/resolve-conflicts-view.css").toExternalForm());
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Resolve conflicts");
alert.setResizable(true);
alert.setDialogPane(root);
alert.initModality(Modality.WINDOW_MODAL);
Window window = alert.getDialogPane().getScene().getWindow();
window.setOnCloseRequest(event -> window.hide());
alert.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
return conflictManagerController.isFinishedSuccessfully();
}
示例3: _showMessageDialog
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static void _showMessageDialog(Window parent, String message, String title, AlertType type, boolean monospace) {
Alert alert = new Alert(type);
alert.initOwner(parent);
alert.setTitle(title);
alert.setHeaderText(title);
alert.setContentText(message);
alert.initModality(Modality.APPLICATION_MODAL);
alert.setResizable(true);
if (monospace) {
Text text = new Text(message);
alert.getDialogPane().setStyle("-fx-padding: 0 10px 0 10px;");
text.setStyle(" -fx-font-family: monospace;");
alert.getDialogPane().contentProperty().set(text);
}
alert.showAndWait();
}
示例4: newFile
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@FXML
public void newFile() {
Alert closeConfirmation = new Alert(
Alert.AlertType.CONFIRMATION,
"Create a new station?",
ButtonType.YES,
ButtonType.NO
);
closeConfirmation.setHeaderText("New station");
closeConfirmation.initModality(Modality.APPLICATION_MODAL);
closeConfirmation.initOwner(root.getScene().getWindow());
Optional<ButtonType> closeResponse = closeConfirmation.showAndWait();
if (ButtonType.YES.equals(closeResponse.get())) {
station = new Station();
updateEditors();
updateTitle();
}
}
示例5: showPropertyContainerEditor
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static void showPropertyContainerEditor(Window owner, KlcPropertyContainer propertyContainer, String title,
String headerText, String contentText) {
Alert alert = new Alert(AlertType.CONFIRMATION, contentText, ButtonType.OK);
alert.setTitle(title);
alert.setHeaderText(headerText);
alert.initOwner(owner);
alert.initModality(Modality.WINDOW_MODAL);
KlcPropertyContainerEditor editor = new KlcPropertyContainerEditor();
editor.setPrefWidth(300);
editor.setPrefHeight(200);
editor.setPropertyContainer(propertyContainer);
alert.getDialogPane().setContent(editor);
alert.showAndWait();
}
示例6: showThrowable
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/** Show error dialog. **/
static void showThrowable(Window parent, Throwable e) {
Main.log(e);
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception");
alert.initOwner(parent);
alert.initModality(Modality.WINDOW_MODAL);
alert.setHeaderText(e.getClass().getName());
alert.setContentText(e.getMessage());
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
String exceptionText = stringWriter.toString();
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
alert.getDialogPane().setExpandableContent(textArea);
alert.showAndWait();
}
示例7: _showConfirmDialog
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static Optional<ButtonType> _showConfirmDialog(Window parent, String message, String title, AlertType type,
ButtonType... buttonTypes) {
Alert alert = new Alert(type, message, buttonTypes);
alert.initOwner(parent);
alert.setTitle(title);
alert.initModality(Modality.APPLICATION_MODAL);
return alert.showAndWait();
}
示例8: getAlert
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static Alert getAlert(String header, String content, AlertType alertType, Modality modality, Window window,
StageStyle style) {
Alert alert = new Alert(alertType);
alert.setTitle(Values.MAIN_TITLE);
alert.setHeaderText(header);
alert.setContentText(content);
alert.initModality(modality);
alert.initOwner(window);
alert.initStyle(style);
return alert;
}
示例9: dialog
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static Alert dialog(Stage stage, String header, String content) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.initOwner(stage);
alert.initModality(Modality.WINDOW_MODAL);
alert.setHeaderText(header);
alert.setContentText(content);
return alert;
}