本文整理匯總了Java中javafx.scene.control.Alert.initOwner方法的典型用法代碼示例。如果您正苦於以下問題:Java Alert.initOwner方法的具體用法?Java Alert.initOwner怎麽用?Java Alert.initOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Alert
的用法示例。
在下文中一共展示了Alert.initOwner方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: _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();
}
示例2: 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();
}
}
示例3: 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();
}
示例4: handleEditEntry
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@FXML
private void handleEditEntry() throws Exception {
Entry selectedEntry = entryTable.getSelectionModel().getSelectedItem();
if (selectedEntry != null) {
boolean okClicked = mainApp.showAppEditDialog(selectedEntry);
if (okClicked) {
// removed description field
}
}
else {
Alert alert = new Alert(AlertType.WARNING);
alert.initOwner(mainApp.getPrimaryStage());
alert.setTitle("No Selection");
alert.setHeaderText("No Entry Selected");
alert.setContentText("Please select an entry in the table.");
alert.showAndWait();
}
}
示例5: handleDeleteEntry
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@FXML
private void handleDeleteEntry() {
int selectedIndex = entryTable.getSelectionModel().getSelectedIndex();
if (selectedIndex >= 0) {
entryTable.getItems().remove(selectedIndex);
}
else {
Alert alert = new Alert(AlertType.WARNING);
alert.initOwner(mainApp.getPrimaryStage());
alert.setTitle("No Selection");
alert.setHeaderText("No Entry Selected");
alert.setContentText("Please select an entry in the table");
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;
}
示例10: alertInfoMsg
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public void alertInfoMsg(Stage stage) {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("알림");
alert.setHeaderText(null);
alert.setContentText(this.msg);
alert.initOwner(stage);
alert.showAndWait();
}
示例11: alertErrorMsg
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public void alertErrorMsg(Stage stage) {
Alert alert = new Alert(AlertType.ERROR);
alert.initOwner(stage);
alert.setTitle("Warning Dialog");
alert.setHeaderText(null);
alert.setContentText(this.msg);
alert.showAndWait();
}
示例12: alertConfirm
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public int alertConfirm(Stage stage) {
int r = 0;
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.initOwner(stage);
alert.setTitle("확인 알림");
alert.setHeaderText(null);
alert.setContentText(this.msg);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
r = 1;
}
return r;
}
示例13: showErrorDialog
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static void showErrorDialog(Stage owner, String title, String error){
Alert alert = new Alert(AlertType.ERROR);
alert.setContentText(error);
alert.setTitle(title);
alert.setHeaderText("");
alert.initOwner(owner);
alert.showAndWait();
}
示例14: isInputValid
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private boolean isInputValid() {
String errorMessage = "";
if ((appTextField.getText() == null) || appTextField.getText().length() == 0) {
errorMessage += "No valid application!\n";
}
if ((usernameTextField.getText() == null) || usernameTextField.getText().length() == 0) {
errorMessage += "No valid username!\n";
}
if ((passwordTextField.getText() == null) || passwordTextField.getText().length() == 0) {
errorMessage += "No valid password!\n";
}
if (errorMessage.length() == 0) {
return true;
}
else {
Alert alert = new Alert(AlertType.ERROR);
alert.initOwner(dialogStage);
alert.setTitle("Invalid Fields");
alert.setHeaderText("Please correct invalid fields");
alert.setContentText(errorMessage);
alert.showAndWait();
return false;
}
}
示例15: doQuestion
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* Makes a question to the user.
*
* @param text
* the text
* @return true, if successful
*/
public static boolean doQuestion(String text , Stage window) {
boolean[] questionAnswer = { false };
// Show Alert
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.initStyle(StageStyle.UTILITY);
alert.initOwner(window);
alert.setHeaderText("Question");
alert.setContentText(text);
alert.showAndWait().ifPresent(answer -> questionAnswer[0] = ( answer == ButtonType.OK ));
return questionAnswer[0];
}