當前位置: 首頁>>代碼示例>>Java>>正文


Java Alert.showAndWait方法代碼示例

本文整理匯總了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;
		}
	}
}
 
開發者ID:esig,項目名稱:dss-demonstrations,代碼行數:21,代碼來源:SignatureController.java

示例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();
        }
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:22,代碼來源:DeskDroidController.java

示例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();
    }
}
 
開發者ID:adr,項目名稱:eadlsync,代碼行數:23,代碼來源:DiffView.java

示例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();
   	}
}
 
開發者ID:coco35700,項目名稱:uPMT,代碼行數:24,代碼來源:MainViewController.java

示例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) {}
}
 
開發者ID:krHasan,項目名稱:Money-Manager,代碼行數:18,代碼來源:SettingsController.java

示例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();
    }
}
 
開發者ID:Kuangcp,項目名稱:MythRedisClient,代碼行數:25,代碼來源:HashAction.java

示例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) {}
}
 
開發者ID:krHasan,項目名稱:Money-Manager,代碼行數:18,代碼來源:SettingsController.java

示例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();
    }
}
 
開發者ID:WaleedMortaja,項目名稱:Elementary-Number-Theory,代碼行數:13,代碼來源:AboutFXMLController.java

示例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);
	}
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:39,代碼來源:Main.java

示例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;
}
 
開發者ID:cbrnrd,項目名稱:AlertFX,代碼行數:12,代碼來源:QuestionBox.java

示例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");

	}
}
 
開發者ID:ScreachFr,項目名稱:titanium,代碼行數:16,代碼來源:MainPane.java

示例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();
}
 
開發者ID:krHasan,項目名稱:Money-Manager,代碼行數:14,代碼來源:TransactionHistoryController.java

示例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();

	}
 
開發者ID:kimyearho,項目名稱:WebtoonDownloadManager,代碼行數:10,代碼來源:AlertSupport.java

示例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();
    }
}
 
開發者ID:kmrifat,項目名稱:Dr-Assistant,代碼行數:12,代碼來源:DrugsController.java

示例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();
}
 
開發者ID:tillind,項目名稱:pandemie,代碼行數:8,代碼來源:IndexController.java


注:本文中的javafx.scene.control.Alert.showAndWait方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。