本文整理匯總了Java中javafx.scene.control.Alert.showAndWait方法的典型用法代碼示例。如果您正苦於以下問題:Java Alert.showAndWait方法的具體用法?Java Alert.showAndWait怎麽用?Java Alert.showAndWait使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Alert
的用法示例。
在下文中一共展示了Alert.showAndWait方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: save
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private void save(DSSDocument signedDocument) {
FileChooser fileChooser = new FileChooser();
fileChooser.setInitialFileName(signedDocument.getName());
MimeType mimeType = signedDocument.getMimeType();
ExtensionFilter extFilter = new ExtensionFilter(mimeType.getMimeTypeString(), "*." + MimeType.getExtension(mimeType));
fileChooser.getExtensionFilters().add(extFilter);
File fileToSave = fileChooser.showSaveDialog(stage);
if (fileToSave != null) {
try {
FileOutputStream fos = new FileOutputStream(fileToSave);
Utils.copy(signedDocument.openStream(), fos);
Utils.closeQuietly(fos);
} catch (Exception e) {
Alert alert = new Alert(AlertType.ERROR, "Unable to save file : " + e.getMessage(), ButtonType.CLOSE);
alert.showAndWait();
return;
}
}
}
示例2: sendNewMessage
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private void sendNewMessage() {
Optional<String> result = SendMessageDialogController.showAndWait(conversation.get());
if (result.isPresent()) {
Conversation conv = conversation.get();
Message message = new Message();
message.setThreadId(conv.getThreadId());
message.setAddress(conv.getParticipant());
message.setBody(result.get());
message.setMine(true);
if (cs.sendMessage(message)) {
conv.getMessages().add(message);
messages.add(message);
} else {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("An error occured while sending the message.");
alert.showAndWait();
}
}
}
示例3: 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();
}
}
示例4: alertRecovery
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public void alertRecovery(){
Alert alert = new Alert(AlertType.CONFIRMATION);
/*alert.setTitle(main._langBundle.getString("recovery"));
alert.setHeaderText(main._langBundle.getString("recovery_alarm"));*/
alert.setTitle("TRADUCTION NEEDED: Recovery");
alert.setHeaderText("TRADUCTION NEEDED: We detected that the application did not close properly. Do you want to recover a copy of the project that was interrupted?");
ButtonType buttonTypeOne = new ButtonType(main._langBundle.getString("ok"));
ButtonType buttonTypeTwo = new ButtonType(main._langBundle.getString("no"));
alert.getButtonTypes().setAll(buttonTypeOne,buttonTypeTwo);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == buttonTypeOne){
Utils.replaceRecovery();
alert.close();
} else if (result.get() == buttonTypeTwo) {
Utils.deleteRecovery();
alert.close();
} else{
System.out.println("IL SEST PASSE UN TRUC");
alert.close();
}
}
示例5: archiveSource
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@FXML
private void archiveSource(ActionEvent event) {
try {
source.archiveSource(sourcecmboArchive.getValue());
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText(sourcecmboArchive.getValue()+ " is Archived Successfully");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 170);
confirmationMsg.showAndWait();
tabSourceInitialize();
} catch (Exception e) {}
}
示例6: setValueByIndex
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* 修改值.
*
* @param key 數據庫中的鍵
* @param nowSelectRow 當前選擇的值
* @param selected 是否選擇值
*/
@Override
public void setValueByIndex(String key, int nowSelectRow, boolean selected) {
if (selected) {
ShowPanel showPanel = new ShowPanel();
boolean ok = showPanel.showValuePanel(false);
if (ok) {
String childKey = dataTable.getSelectionModel().getSelectedItem().getKey();
String value = showPanel.getValueText();
redisHash.save(key, childKey, value);
}
} else {
Alert alert = MyAlert.getInstance(Alert.AlertType.ERROR);
alert.setTitle("錯誤");
alert.setContentText("請選擇一個鍵");
alert.showAndWait();
}
}
示例7: archiveSector
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@FXML
private void archiveSector(ActionEvent event) {
try {
sector.archiveSector(sectorcmboArchive.getValue());
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText(sectorcmboArchive.getValue()+ " is Archived Successfully");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 170);
confirmationMsg.showAndWait();
tabSectorInitialize();
} catch (Exception e) {}
}
示例8: handleopengithublink
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@FXML
private void handleopengithublink(ActionEvent event) {
try {
java.awt.Desktop.getDesktop().browse(java.net.URI.create("https://github.com/WaleedMortaja/Elementary-Number-Theory"));
} catch (IOException e) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Error");
alert.setHeaderText(null);
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
示例9: addProject
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private void addProject(Project project)
{
Project existingProject = getProjectByName(project.getName());
if (existingProject != null)
{
if (existingProject.getPath().equals(project.getPath()))
{
// Projects are the same
showInfoDialogue("This project is already open!");
projectExplorer.expandProject(existingProject);
}
else
{
// Project with the same name already exists
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Confirmation Dialog");
alert.setGraphic(null);
alert.setHeaderText(null);
alert.setContentText("A project with the name \""
+ project.getName()
+ "\" already exists. In order to open this project, you must choose a different name."
+ "\n\n"
+ "Press OK to choose a new name, or Cancel to close this dialog.");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK)
{
boolean renamed = renameProject(project);
if (renamed)
addProject(project);
}
}
}
else
{
projects.add(project);
}
}
示例10: show
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* Shows the alert
* @return <code>true</code> if "Yes" was pressed, else return false
*/
public boolean show(){
alert = new Alert(Alert.AlertType.CONFIRMATION, question, ButtonType.YES, ButtonType.NO);
alert.initStyle(style);
Optional<ButtonType> result = alert.showAndWait();
if (result.isPresent()) if (result.get() == ButtonType.YES) return true;
return false;
}
示例11: removeServerAction
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private void removeServerAction(Event e) {
Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to remove this server ?");
Optional<ButtonType> result = conf.showAndWait();
if (result.isPresent() && result.get().equals(ButtonType.OK)) {
Server s = content.removeSelectedServer();
if (s != null) {
servers.remove(s);
ServerListLoader.writeServerList(servers);
} else
new Alert(AlertType.ERROR, "No selected server");
}
}
示例12: mnuUndo
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@FXML
private void mnuUndo(ActionEvent event) {
String feedback = new Undo().actionUndo();
Stage TransactionHistoryStage = (Stage) btnSignOut.getScene().getWindow();
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Action Successful");
alert.setHeaderText(null);
alert.setContentText(feedback);
alert.setX(TransactionHistoryStage.getX() + 190);
alert.setY(TransactionHistoryStage.getY() + 190);
initialize();
alert.showAndWait();
}
示例13: alertErrorMsg
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public void alertErrorMsg() {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Warning Dialog");
alert.setHeaderText(null);
alert.setContentText(this.msg);
alert.showAndWait();
}
示例14: deleteDrug
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private void deleteDrug(int drugId, String name) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Delete patient ?");
alert.setHeaderText("Delete " + name + " ?");
alert.setContentText("Are you sure to delete this drug ?");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
drugGetway.delete(drugId);
loadDrugs();
}
}
示例15: printAlert
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private void printAlert(Alert.AlertType type){
Alert alert = new Alert(type);
alert.setTitle("Warning Dialog");
alert.setHeaderText("Look, a Warning Dialog");
alert.setContentText("Careful with the next step!");
alert.showAndWait();
}